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;
long long plan_roller_coaster(vector<int> s,vector<int> t){
int n = (int) s.size();
vector<pair<int,int>> s2;
vector<int> vec;
for(int i=0;i<n;i++){
vec.push_back(0);
if(t[i]<=s[i])vec[i]--;
s2.push_back({t[i],i});
}
sort(s.begin(),s.end());
reverse(s.begin(),s.end());
sort(s2.begin(),s2.end());
for(int i=0;i<n;i++){
int l=0,r=n-1,h=s2[i].first,ans=-1;
while(l<=r){
int mid=(l+r)/2;
if(s[mid]>=h){
ans=mid;
l=mid+1;
}
else{
r=mid-1;
}
}
vec[s2[i].second]+=ans;
}
sort(vec.begin(),vec.end());
for(int i=0;i<n;i++){
if(vec[i]<i)return 0;
}
return 1;
}
# | 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... |