#include "gap.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
ll findGap(int T, int n){
if(T == 1){
ll ans = 0, a, b;
MinMax(0, 1e18, &a, &b);
for(int i = 0; i < (n+1)/2-1; i++){
ll x, y;
MinMax(a+1, b-1, &x, &y);
ans = max(ans, max(x-a, b-y));
a = x, b = y;
}
if(n%2 == 0) ans = max(ans, b-a);
return ans;
}
ll ans = 0, a, b;
MinMax(0, 1e18, &a, &b);
ll k = (b-a+n-2)/(n-1);
ll prev = a;
int cnt = 0;
for(ll i = a; i <= b; i+=k){
cnt++;
ll x, y;
if(i == b) x = b, y = b;
else MinMax(i, min(i+k-1, b), &x, &y);
if(x == -1) continue;
ans = max(ans, x-prev);
prev = y;
}
assert(cnt <= n);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
220 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
9 ms |
464 KB |
Output is correct |
17 |
Correct |
10 ms |
432 KB |
Output is correct |
18 |
Correct |
10 ms |
428 KB |
Output is correct |
19 |
Correct |
10 ms |
464 KB |
Output is correct |
20 |
Correct |
7 ms |
464 KB |
Output is correct |
21 |
Correct |
40 ms |
988 KB |
Output is correct |
22 |
Correct |
39 ms |
1192 KB |
Output is correct |
23 |
Correct |
35 ms |
1204 KB |
Output is correct |
24 |
Correct |
36 ms |
964 KB |
Output is correct |
25 |
Correct |
31 ms |
1060 KB |
Output is correct |
26 |
Correct |
44 ms |
1076 KB |
Output is correct |
27 |
Correct |
37 ms |
972 KB |
Output is correct |
28 |
Correct |
36 ms |
1088 KB |
Output is correct |
29 |
Correct |
37 ms |
1084 KB |
Output is correct |
30 |
Correct |
29 ms |
1092 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
13 ms |
516 KB |
Output is correct |
17 |
Correct |
15 ms |
516 KB |
Output is correct |
18 |
Correct |
12 ms |
464 KB |
Output is correct |
19 |
Correct |
12 ms |
508 KB |
Output is correct |
20 |
Correct |
6 ms |
464 KB |
Output is correct |
21 |
Correct |
50 ms |
1024 KB |
Output is correct |
22 |
Correct |
51 ms |
1060 KB |
Output is correct |
23 |
Correct |
56 ms |
1064 KB |
Output is correct |
24 |
Correct |
56 ms |
1176 KB |
Output is correct |
25 |
Correct |
50 ms |
1028 KB |
Output is correct |
26 |
Correct |
56 ms |
1012 KB |
Output is correct |
27 |
Correct |
53 ms |
1056 KB |
Output is correct |
28 |
Correct |
52 ms |
1084 KB |
Output is correct |
29 |
Correct |
55 ms |
1112 KB |
Output is correct |
30 |
Correct |
28 ms |
1064 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |