Submission #1029636

#TimeUsernameProblemLanguageResultExecution timeMemory
102963612345678Roller Coaster Railroad (IOI16_railroad)C++17
0 / 100
445 ms47992 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; const int nx=2e5+5; int n, T, cnts, cntt; map<int, int> mp; vector<pair<int, int>> v[2*nx]; 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 ++) v[mp[s[i]]].push_back({0, i}), v[mp[t[i]]].push_back({1, i}); //cout<<"mp "<<mp[s[i]]<<' '<<mp[t[i]]<<'\n'; for (int i=2*n; i>=1; i--) { sort(v[i].begin(), v[i].end()); for (auto x:v[i]) { if (!x.first) { //cout<<"update "<<x.second<<' '<<cnts<<'\n'; cnts++; } else { cntt++; int vl=cnts; //if (t[x.second]<=s[x.second]) vl=cnts-1; //cout<<"debug "<<x.second<<' '<<vl<<' '<<cntt<<'\n'; if (vl<cntt-1) return 1; } } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...