#include<bits/stdc++.h>
#include"light.h"
typedef long long ll;
using namespace std;
ll N = 1;
vector<ll> act = {1};
void prepare() {
}
pair<ll, vector<ll>> solve(ll p) {
vector<ll> ret = {N};
ll x = N;
while (x > 1) {
x -= min(x - 1, N - x + 2);
int i = upper_bound(act.begin(), act.end(), x+1) - act.begin() - 1;
if (x - act[i] > p)
x = act[i + 1];
ret.insert(ret.begin(), x);
}
swap(ret, act);
return {p, act};
}
pair<ll, vector<ll>> join(ll p) {
N += p;
return solve(p);
}
pair<ll, vector<ll>> leave(ll p) {
N -= p;
return solve(p);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
288 ms |
344 KB |
Correct |
3 |
Correct |
301 ms |
344 KB |
Correct |
4 |
Correct |
313 ms |
344 KB |
Correct |
5 |
Correct |
287 ms |
344 KB |
Correct |
6 |
Correct |
335 ms |
344 KB |
Correct |
7 |
Correct |
304 ms |
344 KB |
Correct |
8 |
Correct |
292 ms |
344 KB |
Correct |
9 |
Correct |
282 ms |
344 KB |
Correct |
10 |
Correct |
277 ms |
344 KB |
Correct |
11 |
Correct |
325 ms |
340 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
1 ms |
344 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
1 ms |
344 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
1 ms |
344 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
1 ms |
344 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
1 ms |
344 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
265 ms |
432 KB |
Correct |
3 |
Correct |
278 ms |
760 KB |
Correct |
4 |
Correct |
278 ms |
344 KB |
Correct |
5 |
Correct |
275 ms |
344 KB |
Correct |
6 |
Correct |
285 ms |
424 KB |
Correct |
7 |
Correct |
284 ms |
344 KB |
Correct |
8 |
Correct |
285 ms |
596 KB |
Correct |
9 |
Correct |
258 ms |
344 KB |
Correct |
10 |
Correct |
254 ms |
344 KB |
Correct |
11 |
Correct |
250 ms |
596 KB |
Correct |
12 |
Incorrect |
1 ms |
344 KB |
Not correct |
13 |
Halted |
0 ms |
0 KB |
- |