#include "gap.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define ss(x) (int) x.size()
#define pb push_back
#define ll long long
#define cat(x) cerr << #x << " = " << x << endl
#define FOR(i, n) for(int i = 0; i < n; ++i)
using namespace std;
ll findGap(int t, int n) {
if(t == 1) {
vector <ll> v;
ll L = 0;
ll R = 1e18;
while(L <= R) {
ll LL, RR;
MinMax(L, R, &LL, &RR);
if(LL == -1) break;
v.pb(LL);
if(LL != RR)
v.pb(RR);
if(ss(v) == n)
break;
L = LL + 1;
R = RR - 1;
}
sort(v.begin(), v.end());
ll ans = 0;
for(int i = 0; i + 1 < ss(v); ++i)
ans = max(ans, v[i + 1] - v[i]);
return ans;
}
// t = 2
ll L = 0;
ll R = 1e18;
ll LL, RR;
MinMax(L, R, &LL, &RR);
ll ans = (RR - LL + n - 2) / (n - 1);
ll Last = -1;
L = LL;
R = RR;
ll P = ans;
while(L <= R) {
MinMax(L, L + P, &LL, &RR);
if(LL == -1) {
L += P + 1;
continue;
}
if(Last != -1) {
ans = max(ans, LL - Last);
}
Last = RR;
L += P + 1;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
16 ms |
888 KB |
Output is correct |
17 |
Correct |
16 ms |
988 KB |
Output is correct |
18 |
Correct |
16 ms |
888 KB |
Output is correct |
19 |
Correct |
16 ms |
888 KB |
Output is correct |
20 |
Correct |
12 ms |
888 KB |
Output is correct |
21 |
Correct |
60 ms |
2348 KB |
Output is correct |
22 |
Correct |
60 ms |
2296 KB |
Output is correct |
23 |
Correct |
60 ms |
2412 KB |
Output is correct |
24 |
Correct |
60 ms |
2324 KB |
Output is correct |
25 |
Correct |
52 ms |
2288 KB |
Output is correct |
26 |
Correct |
60 ms |
2288 KB |
Output is correct |
27 |
Correct |
61 ms |
2288 KB |
Output is correct |
28 |
Correct |
60 ms |
2292 KB |
Output is correct |
29 |
Correct |
60 ms |
2416 KB |
Output is correct |
30 |
Correct |
46 ms |
2288 KB |
Output is correct |
31 |
Correct |
0 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
380 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
4 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
380 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
19 ms |
504 KB |
Output is correct |
17 |
Correct |
19 ms |
504 KB |
Output is correct |
18 |
Correct |
19 ms |
504 KB |
Output is correct |
19 |
Correct |
19 ms |
504 KB |
Output is correct |
20 |
Correct |
10 ms |
504 KB |
Output is correct |
21 |
Correct |
73 ms |
1196 KB |
Output is correct |
22 |
Correct |
72 ms |
1144 KB |
Output is correct |
23 |
Correct |
72 ms |
1144 KB |
Output is correct |
24 |
Correct |
72 ms |
1144 KB |
Output is correct |
25 |
Correct |
67 ms |
1144 KB |
Output is correct |
26 |
Correct |
73 ms |
1144 KB |
Output is correct |
27 |
Correct |
72 ms |
1144 KB |
Output is correct |
28 |
Correct |
72 ms |
1148 KB |
Output is correct |
29 |
Correct |
73 ms |
1144 KB |
Output is correct |
30 |
Correct |
36 ms |
1144 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |