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;
#define int long long
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define fi first
#define se second
const int inf = 1e16 + 42;
int n;
vector<int> in;
vector<int> out;
bool solve() {
vector<pii > events;
for(int i = 0; i < n; i++) {
events.pb(mp(in[i], 1));
events.pb(mp(out[i], -1));
}
sort(events.rbegin(), events.rend());
int cnt = 0;
bool was = false;
for(pii p : events) {
if(p.se == 1) {
cnt++;
} else {
if(cnt > 0) {
cnt--;
} else {
if(was) {
return true;
} else {
was = true;
}
}
}
}
return false;
}
int plan_roller_coaster(vector<signed> s, vector<signed> t) {
n = (int) s.size();
in.assign(n, 0);
out.assign(n, 0);
for(int i = 0; i < n; i++) {
in[i] = s[i];
out[i] = t[i];
}
return (int) solve();
}
/*
8
0 3
1 5
2 4
3 0
4 2
5 4
6 7
7 5
*/
# | 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... |