Submission #1036320

#TimeUsernameProblemLanguageResultExecution timeMemory
103632012345678Roller Coaster Railroad (IOI16_railroad)C++17
0 / 100
311 ms29228 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; const int nx=4e5+5; int n, T, qsl[nx], qsr[nx], ans; map<int, int> mp; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { n=s.size(); for (int i=0; i<n; i++) mp[s[i]]=mp[t[i]]=0; for (auto &[x, y]:mp) y=++T; for (int i=0; i<n; i++) { if (s[i]<t[i]) qsr[mp[s[i]]]++, qsr[mp[t[i]]]--; else qsl[mp[t[i]]]++, qsl[mp[s[i]]]--; } for (int i=1; i<=2*n; i++) qsr[i]+=qsr[i-1], qsl[i]+=qsl[i-1]; for (int i=1; i<=2*n; i++) if (qsr[i]-1>qsl[i]) ans=1; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...