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>
#define lli long long int
#define fr first
#define sc second
#define all(x) (x).begin(), (x).end()
using namespace std;
const int N = 2e5 + 30;
int n;
pair <int, int> a[N];
long long plan_roller_coaster(vector<int> s, vector<int> t)
{
n = s.size();
for (int i = 0; i < n; i++)
{
a[i].fr = s[i];
a[i].sc = t[i];
}
sort(a, a + n);
sort(all(t));
if(a[0].fr < t[0] && a[0].sc > a[n-1].fr) return 1;
for (int i = 0; i < n; i++)
{
int sm = 1;
while(i < n - 1 && a[i].fr == a[i + 1].fr) sm++, i++;
int i1 = upper_bound(all(t), a[i].fr) - t.begin();
if(sm == 1 && a[i].fr >= a[i].sc)
{
if(!i || a[i - 1].fr < a[i].sc) i1--;
}
if(i1 < i) return 1;
if(i == 0 && i1 == 0 && a[0].sc > a[n-1].fr) return 1;
if(i == 0 && i1 == 0 && a[0].sc == t[n-1] && a[0].sc > a[n-2].fr) return 1;
}
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... |