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;
const int nx=4e5+5;
int n, T, qsl[nx], qsr[nx], ans;
map<int, int> mp;
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
n=s.size();
for (int i=0; i<n; i++) mp[s[i]]=mp[t[i]]=0;
for (auto &[x, y]:mp) y=++T;
for (int i=0; i<n; i++)
{
if (s[i]<t[i]) qsr[mp[s[i]]]++, qsr[mp[t[i]]]--;
else qsl[mp[t[i]]]++, qsl[mp[s[i]]]--;
}
for (int i=1; i<=2*n; i++) qsr[i]+=qsr[i-1], qsl[i]+=qsl[i-1];
for (int i=1; i<=2*n; i++) if (qsr[i]-1>qsl[i]) ans=1;
return ans;
}
# | 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... |