Submission #1022137

#TimeUsernameProblemLanguageResultExecution timeMemory
1022137amirhoseinfar1385Roller Coaster Railroad (IOI16_railroad)C++17
30 / 100
94 ms18880 KiB
#include "railroad.h" #include<bits/stdc++.h> using namespace std; vector<int>allind; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = (int) s.size(); vector<pair<long long ,long long>>allt,alls; int now=0; for(auto x:s){ alls.push_back(make_pair(x,now)); now++; } now=0; for(auto x:t){ allt.push_back(make_pair(x,now)); now++; } allt.push_back(make_pair(1,now)); sort(allt.begin(),allt.end()); sort(alls.begin(),alls.end()); long long res=0; for(int i=0;i<n;i++){ if(allt[i].first==t[alls[i].second]){ swap(allt[i],allt[i+1]); } // cout<<allt[i].first<<" "<<alls[i].first<<" "<<allt[i+1].first<<endl; res+=max(0ll,allt[i].first-alls[i].first); } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...