#include "gap.h"
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxn = 2*1e5+5, INF = 4e18+9;
long long findGap(int T, int n)
{
ll ans = 0;
if(T == 1){
ll l = 0, r = INF;
ll mn, mx;
vector<ll> a(n+1);
for(int i = 1; i <= (n+1)/2; i++){
MinMax(l, r, &mn, &mx);
a[i] = mn; a[n-i+1] = mx;
l = mn+1, r = mx-1;
}
for(int i = 2; i <= n; i++){
ans = max(ans, a[i]-a[i-1]);
}
}else{
ll l = 0, r = INF;
ll mn, mx;
vector<ll> a(n+1);
MinMax(l, r, &mn, &mx);
l = mn, r = mx;
ll d = (r-l)/n;
while(l < r){
MinMax(l+1, l+d, &mn, &mx);
if(mn != -1){
l = mx;
continue;
}
MinMax(l+1, l+d*2, &mn, &mx);
ll t = mn;
while(t == -1){
d*=2;
MinMax(l+1, l+d*2, &mn, &mx);
t = mn;
}
d = max(d, t-l);
l = mx;
}
ans = d;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
596 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
440 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
7 ms |
856 KB |
Output is correct |
17 |
Correct |
7 ms |
856 KB |
Output is correct |
18 |
Correct |
7 ms |
856 KB |
Output is correct |
19 |
Correct |
6 ms |
856 KB |
Output is correct |
20 |
Correct |
7 ms |
856 KB |
Output is correct |
21 |
Correct |
34 ms |
1832 KB |
Output is correct |
22 |
Correct |
43 ms |
1880 KB |
Output is correct |
23 |
Correct |
35 ms |
1884 KB |
Output is correct |
24 |
Correct |
39 ms |
1972 KB |
Output is correct |
25 |
Correct |
25 ms |
1968 KB |
Output is correct |
26 |
Correct |
25 ms |
1880 KB |
Output is correct |
27 |
Correct |
28 ms |
1880 KB |
Output is correct |
28 |
Correct |
40 ms |
1908 KB |
Output is correct |
29 |
Correct |
28 ms |
1880 KB |
Output is correct |
30 |
Correct |
26 ms |
1836 KB |
Output is correct |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
Partially correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
2 ms |
344 KB |
Output is correct |
16 |
Correct |
5 ms |
856 KB |
Output is correct |
17 |
Correct |
5 ms |
856 KB |
Output is correct |
18 |
Correct |
5 ms |
660 KB |
Output is correct |
19 |
Correct |
5 ms |
672 KB |
Output is correct |
20 |
Correct |
3 ms |
856 KB |
Output is correct |
21 |
Correct |
29 ms |
1872 KB |
Output is correct |
22 |
Correct |
25 ms |
1880 KB |
Output is correct |
23 |
Correct |
18 ms |
1880 KB |
Output is correct |
24 |
Correct |
24 ms |
1876 KB |
Output is correct |
25 |
Correct |
34 ms |
1880 KB |
Output is correct |
26 |
Correct |
18 ms |
1880 KB |
Output is correct |
27 |
Correct |
19 ms |
1880 KB |
Output is correct |
28 |
Correct |
18 ms |
1880 KB |
Output is correct |
29 |
Correct |
29 ms |
1872 KB |
Output is correct |
30 |
Correct |
9 ms |
1880 KB |
Output is correct |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |