제출 #1022137

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
10221372024-07-13 10:25:57amirhoseinfar1385Roller 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;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...