Submission #2520468
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define REP(i,a,b) for(int i=a;i<b;i++) #define rep(i,n) REP(i,0,n) typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<ll> vl; ll N, L; vector<pair<ll,int>> r; ll ans = 0; int main() { //cin.tie(0); //ios::sync_with_stdio(false); cin >> N >> L; r.resize(N); rep(i,N) { ll x, d; char c; cin >> x >> c; if (c == 'R') d = 1; else d = 0; r[i] = pair<ll,int>(x,d); } sort(r.begin(), r.end()); rep(i,N) { if (r[i].second == 1) { int j = i; while (j < N && r[j].second == 1) j++; ll e = 0; ll c1 = 0; for (int k = j-1; k >= i; k--) { if (k == N-1) e += L - r[k].first; else e += r[k+1].first - r[k].first - 1; c1 += e; } int jj = j; while (jj < N && r[jj].second == 0) jj++; e = 0; ll c2 = 0; for (int k = j; k < jj; k++) { e += r[k].first - r[k-1].first - 1; c2 += e; } //cout << c1 << " " << c2 << endl; ans += max(c1, c2); i = jj-1; } else { int j = i; while (j < N && r[j].second == 0) j++; ll e = 0; ll c1 = 0; for (int k = i; k < j; k++) { if (k==0) e += r[k].first - 1; else e += r[k].first - r[k-1].first - 1; c1 += e; } ans += c1; i = j-1; } } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - ウサギ跳び |
User | bluenote |
Language | C++ (GCC 5.4.1) |
Score | 0 |
Code Size | 1763 Byte |
Status | CE |
Compile Error
./Main.cpp:14:19: error: ‘>>’ should be ‘> >’ within a nested template argument list vector<pair<ll,int>> r; ^