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;
typedef long long ll;
const int maxn = 16;
const ll inf = 1e18;
ll plan_roller_coaster(vector<int> s, vector<int> t){
int n = (int)s.size();
vector<pair<int,int>> tmp(n);
for (int i = 0; i < n; i++)
tmp[i] = {s[i],t[i]};
sort(tmp.begin(), tmp.end());
for (int i = 0; i < n; i++)
s[i] = tmp[i].first, t[i] = tmp[i].second;
int start = 0;
if (t[0] > s[n-1])
start = 1;
set<pair<int,int>> S;
for (int i = 0; i < n; i++)
if (i != start)
S.insert({s[i],i});
while (!S.empty()){
auto it = S.lower_bound(make_pair(t[start],-1));
if (it == S.end())
return 1;
start = (*it).second;
S.erase(it);
}
return 0;
}
# | 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... |