This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// name = railroad_gk_wa.cpp, type = cpp.g++11
#include "railroad.h"
#include <bits/stdc++.h>
using namespace std;
long long plan_roller_coaster(vector<int> s, vector<int> t) {
int n = s.size();
vector < pair <int, int> > e;
for (int i = 0; i < n; i++) {
e.push_back(make_pair(s[i], 1));
e.push_back(make_pair(t[i], -1));
}
sort(e.begin(), e.end());
int sz = e.size();
int balance = 0;
bool source = false;
int beg = 0;
while (beg < sz) {
int end = beg;
while (end + 1 < sz && e[end + 1].first == e[end].first) {
end++;
}
for (int j = beg; j <= end; j++) {
balance += e[j].second;
}
if (balance > 1) {
return 1;
}
if (balance == 1) {
if (source) {
return 1;
}
balance--;
source = true;
}
beg = end + 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... |