#include "gap.h"
#include <algorithm>
#include <iostream>
using namespace std;
const long long MIN = 0;
const long long MAX = 1'000'000'000'000'000'000;
long long findGap(int T, int N)
{
if (T == 1) {
long long mn, mx;
long long prev_mn, prev_mx;
long long sol = 0;
MinMax(MIN, MAX, &prev_mn, &prev_mx);
for (int i = 3; i <= N; i+=2) {
MinMax(prev_mn+1, prev_mx-1, &mn, &mx);
sol = max(sol, prev_mx-mx);
sol = max(sol, mn-prev_mn);
}
return sol;
} else if (T == 2) {
long long mn, mx;
MinMax(MIN, MAX, &mn, &mx);
long long diff = (mx-mn+1 + N-2)/(N-1), sol = 0, prev_mx = MAX, st = mn;
while (st <= mx) {
long long en = min(MAX, st+diff-1), cur_mn, cur_mx;
MinMax(st, en, &cur_mn, &cur_mx);
cerr << st << ' ' << en << ' ' << cur_mn << ' ' << cur_mx << endl;
if (cur_mn != -1) {
sol = max(sol, cur_mn - prev_mx);
prev_mx = cur_mx;
}
st += diff;
cerr << "ST " << st << ' ' << mx << endl;
}
return sol;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:39:1: warning: control reaches end of non-void function [-Wreturn-type]
39 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2392 KB |
Output is correct |
6 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
2392 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
2392 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
14 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Incorrect |
5 ms |
2392 KB |
Output isn't correct |
17 |
Incorrect |
5 ms |
2644 KB |
Output isn't correct |
18 |
Incorrect |
7 ms |
2392 KB |
Output isn't correct |
19 |
Incorrect |
7 ms |
2500 KB |
Output isn't correct |
20 |
Incorrect |
4 ms |
2392 KB |
Output isn't correct |
21 |
Incorrect |
18 ms |
2736 KB |
Output isn't correct |
22 |
Incorrect |
18 ms |
2648 KB |
Output isn't correct |
23 |
Incorrect |
21 ms |
2648 KB |
Output isn't correct |
24 |
Incorrect |
18 ms |
2648 KB |
Output isn't correct |
25 |
Correct |
15 ms |
2648 KB |
Output is correct |
26 |
Incorrect |
18 ms |
2648 KB |
Output isn't correct |
27 |
Incorrect |
24 ms |
2648 KB |
Output isn't correct |
28 |
Incorrect |
24 ms |
2648 KB |
Output isn't correct |
29 |
Incorrect |
18 ms |
2796 KB |
Output isn't correct |
30 |
Incorrect |
14 ms |
2648 KB |
Output isn't correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
0 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
2 ms |
2392 KB |
Output is correct |
7 |
Correct |
2 ms |
2392 KB |
Output is correct |
8 |
Correct |
2 ms |
2392 KB |
Output is correct |
9 |
Correct |
2 ms |
2392 KB |
Output is correct |
10 |
Correct |
2 ms |
2392 KB |
Output is correct |
11 |
Correct |
20 ms |
2592 KB |
Output is correct |
12 |
Correct |
20 ms |
2648 KB |
Output is correct |
13 |
Correct |
20 ms |
2648 KB |
Output is correct |
14 |
Correct |
20 ms |
2648 KB |
Output is correct |
15 |
Correct |
19 ms |
2584 KB |
Output is correct |
16 |
Correct |
326 ms |
5004 KB |
Output is correct |
17 |
Correct |
324 ms |
5200 KB |
Output is correct |
18 |
Correct |
325 ms |
4944 KB |
Output is correct |
19 |
Correct |
329 ms |
5188 KB |
Output is correct |
20 |
Correct |
320 ms |
3444 KB |
Output is correct |
21 |
Correct |
1303 ms |
13136 KB |
Output is correct |
22 |
Correct |
1285 ms |
13136 KB |
Output is correct |
23 |
Correct |
1389 ms |
13372 KB |
Output is correct |
24 |
Correct |
1240 ms |
13136 KB |
Output is correct |
25 |
Correct |
1331 ms |
10524 KB |
Output is correct |
26 |
Correct |
1250 ms |
13184 KB |
Output is correct |
27 |
Correct |
1248 ms |
13164 KB |
Output is correct |
28 |
Correct |
1300 ms |
13276 KB |
Output is correct |
29 |
Correct |
1273 ms |
13136 KB |
Output is correct |
30 |
Correct |
1305 ms |
6480 KB |
Output is correct |
31 |
Correct |
2 ms |
2392 KB |
Output is correct |
32 |
Correct |
2 ms |
2392 KB |
Output is correct |