This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |