#include <bits/stdc++.h>
#include "railroad.h"
//#include "grader.cpp"
using namespace std ;
vector<int>a , b ;
int n ;
vector< pair<int , int> >vp ;
bool solve(pair<int , int>p)
{
set< pair<int , int> >s ;
set< pair<int , int> >::iterator it ;
for(int i = 0 ; i < n ; ++i)
s.insert(vp[i]) ;
for(int i = 0 ; i < n-1 ; ++i)
{
s.erase(p) ;
it = s.lower_bound({p.second , -1}) ;
if(it == s.end())
return 0 ;
p = *it ;
}
return 1 ;
}
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
n = (int) s.size();
a = s , b = t ;
for(int i = 0 ; i < n ; ++i)
vp.push_back({a[i] , b[i]}) ;
sort(vp.begin() , vp.end()) ;
if(solve(vp[0]) == 1)
return 0 ;
if(solve(vp[1]) == 1)
return 0 ;
return 1 ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
292 KB |
n = 2 |
2 |
Correct |
2 ms |
376 KB |
n = 2 |
3 |
Correct |
2 ms |
376 KB |
n = 2 |
4 |
Correct |
2 ms |
256 KB |
n = 2 |
5 |
Correct |
2 ms |
376 KB |
n = 2 |
6 |
Incorrect |
2 ms |
256 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 |
292 KB |
n = 2 |
2 |
Correct |
2 ms |
376 KB |
n = 2 |
3 |
Correct |
2 ms |
376 KB |
n = 2 |
4 |
Correct |
2 ms |
256 KB |
n = 2 |
5 |
Correct |
2 ms |
376 KB |
n = 2 |
6 |
Incorrect |
2 ms |
256 KB |
answer is not correct: 1 instead of 523688153 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
195 ms |
19848 KB |
n = 199999 |
2 |
Correct |
278 ms |
19908 KB |
n = 199991 |
3 |
Correct |
235 ms |
19944 KB |
n = 199993 |
4 |
Correct |
176 ms |
15080 KB |
n = 152076 |
5 |
Correct |
114 ms |
9432 KB |
n = 93249 |
6 |
Incorrect |
267 ms |
18828 KB |
answer is not correct: 1 instead of 0 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
292 KB |
n = 2 |
2 |
Correct |
2 ms |
376 KB |
n = 2 |
3 |
Correct |
2 ms |
376 KB |
n = 2 |
4 |
Correct |
2 ms |
256 KB |
n = 2 |
5 |
Correct |
2 ms |
376 KB |
n = 2 |
6 |
Incorrect |
2 ms |
256 KB |
answer is not correct: 1 instead of 523688153 |
7 |
Halted |
0 ms |
0 KB |
- |