#include "railroad.h"
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const ll INF=1e18+7;
ll plan_roller_coaster(vector<int>S, vector<int>T) {
int n=S.size();
vector<pair<ll,ll>>V;
rep(i, n) {
V.pb({S[i], 1});
V.pb({T[i], -1});
}
sort(all(V));
ll lst=V[0].st, sum=-1, ans=0;
int czy=0;
for(auto i : V) {
sum+=i.nd;
if(i.st!=lst) {
if(sum!=0) {
if(czy==2) {
return 1;
}
czy=1;
} else if(czy==1) czy=2;
}
ans+=(i.st-lst)*max(sum, 0ll);
lst=i.st;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
n = 2 |
2 |
Correct |
0 ms |
360 KB |
n = 2 |
3 |
Correct |
0 ms |
360 KB |
n = 2 |
4 |
Correct |
0 ms |
360 KB |
n = 2 |
5 |
Correct |
1 ms |
360 KB |
n = 2 |
6 |
Incorrect |
0 ms |
360 KB |
answer is not correct: 1 instead of 523688153 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
n = 2 |
2 |
Correct |
0 ms |
360 KB |
n = 2 |
3 |
Correct |
0 ms |
360 KB |
n = 2 |
4 |
Correct |
0 ms |
360 KB |
n = 2 |
5 |
Correct |
1 ms |
360 KB |
n = 2 |
6 |
Incorrect |
0 ms |
360 KB |
answer is not correct: 1 instead of 523688153 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
76 ms |
12492 KB |
n = 199999 |
2 |
Correct |
68 ms |
12624 KB |
n = 199991 |
3 |
Correct |
75 ms |
13692 KB |
n = 199993 |
4 |
Correct |
59 ms |
11976 KB |
n = 152076 |
5 |
Correct |
42 ms |
6656 KB |
n = 93249 |
6 |
Correct |
69 ms |
13756 KB |
n = 199910 |
7 |
Correct |
65 ms |
12732 KB |
n = 199999 |
8 |
Correct |
62 ms |
13760 KB |
n = 199997 |
9 |
Correct |
62 ms |
12480 KB |
n = 171294 |
10 |
Incorrect |
48 ms |
13008 KB |
answer is not correct: 1 instead of 0 |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
n = 2 |
2 |
Correct |
0 ms |
360 KB |
n = 2 |
3 |
Correct |
0 ms |
360 KB |
n = 2 |
4 |
Correct |
0 ms |
360 KB |
n = 2 |
5 |
Correct |
1 ms |
360 KB |
n = 2 |
6 |
Incorrect |
0 ms |
360 KB |
answer is not correct: 1 instead of 523688153 |
7 |
Halted |
0 ms |
0 KB |
- |