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<bits/stdc++.h>
using namespace std;
//#include "railroad.h"
vector<pair<int,int> > v;
map<int,int> same;
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int n = (int) s.size();
for(int i=0;i<n;i++){
if(s[i]==t[i]){
v.push_back(make_pair(s[i],1));
continue;
}
v.push_back(make_pair(s[i],2));
v.push_back(make_pair(t[i],0));
}
sort(v.begin(),v.end());
bool ok=false;
int stk=0;
int en=0;
while( v.size() ) {
auto f=v.back();
v.pop_back();
if(f.second==2){
stk++;
}
else{
if(f.second==1){
v.push_back(make_pair(f.first,2));
v.push_back(make_pair(f.first,0));
continue;
}
if(stk){
stk--;
continue;
}
if(stk==0){
if(en==0){
en=1;
continue;
}
ok=true;
break;
}
}
}
return ok;
}
# | 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... |