// 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 |
1 |
Correct |
2 ms |
256 KB |
n = 2 |
2 |
Correct |
2 ms |
384 KB |
n = 2 |
3 |
Correct |
2 ms |
256 KB |
n = 2 |
4 |
Correct |
2 ms |
256 KB |
n = 2 |
5 |
Correct |
2 ms |
256 KB |
n = 2 |
6 |
Incorrect |
2 ms |
384 KB |
answer is not correct: 1 instead of 523688153 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
n = 2 |
2 |
Correct |
2 ms |
384 KB |
n = 2 |
3 |
Correct |
2 ms |
256 KB |
n = 2 |
4 |
Correct |
2 ms |
256 KB |
n = 2 |
5 |
Correct |
2 ms |
256 KB |
n = 2 |
6 |
Incorrect |
2 ms |
384 KB |
answer is not correct: 1 instead of 523688153 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
7656 KB |
n = 199999 |
2 |
Correct |
114 ms |
7788 KB |
n = 199991 |
3 |
Correct |
119 ms |
7680 KB |
n = 199993 |
4 |
Correct |
79 ms |
6964 KB |
n = 152076 |
5 |
Correct |
49 ms |
3948 KB |
n = 93249 |
6 |
Correct |
89 ms |
7788 KB |
n = 199910 |
7 |
Correct |
101 ms |
7688 KB |
n = 199999 |
8 |
Correct |
89 ms |
7784 KB |
n = 199997 |
9 |
Correct |
96 ms |
7272 KB |
n = 171294 |
10 |
Correct |
82 ms |
6760 KB |
n = 140872 |
11 |
Incorrect |
95 ms |
7784 KB |
answer is not correct: 0 instead of 1 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
n = 2 |
2 |
Correct |
2 ms |
384 KB |
n = 2 |
3 |
Correct |
2 ms |
256 KB |
n = 2 |
4 |
Correct |
2 ms |
256 KB |
n = 2 |
5 |
Correct |
2 ms |
256 KB |
n = 2 |
6 |
Incorrect |
2 ms |
384 KB |
answer is not correct: 1 instead of 523688153 |
7 |
Halted |
0 ms |
0 KB |
- |