#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);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
269 ms |
588 KB |
Correct |
3 |
Correct |
261 ms |
428 KB |
Correct |
4 |
Correct |
281 ms |
416 KB |
Correct |
5 |
Correct |
277 ms |
344 KB |
Correct |
6 |
Correct |
265 ms |
416 KB |
Correct |
7 |
Correct |
269 ms |
344 KB |
Correct |
8 |
Correct |
272 ms |
432 KB |
Correct |
9 |
Correct |
290 ms |
600 KB |
Correct |
10 |
Correct |
293 ms |
432 KB |
Correct |
11 |
Incorrect |
0 ms |
344 KB |
Not correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Execution timed out |
3016 ms |
2608 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Execution timed out |
3016 ms |
2608 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Execution timed out |
3016 ms |
2608 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Execution timed out |
3016 ms |
2608 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Execution timed out |
3016 ms |
2608 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
293 ms |
424 KB |
Correct |
3 |
Correct |
288 ms |
600 KB |
Correct |
4 |
Correct |
302 ms |
600 KB |
Correct |
5 |
Correct |
291 ms |
344 KB |
Correct |
6 |
Correct |
294 ms |
432 KB |
Correct |
7 |
Correct |
300 ms |
412 KB |
Correct |
8 |
Correct |
307 ms |
344 KB |
Correct |
9 |
Correct |
265 ms |
344 KB |
Correct |
10 |
Correct |
268 ms |
432 KB |
Correct |
11 |
Incorrect |
0 ms |
344 KB |
Not correct |
12 |
Halted |
0 ms |
0 KB |
- |