#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
typedef long long ll;
const ll INF = 1e18;
ll solve1(int n) {
ll a[n]={};
ll lf=-1, rf=INF+1, lp=0, rp=n-1;
while (lp <= rp) {
ll mn, mx; MinMax(lf+1, rf-1, &mn, &mx);
if (mn == -1) break;
a[lp++]=mn, a[rp--]=mx;
lf=mn, rf=mx;
}
ll ans=1;
for (int i=0; i<n-1; ++i) ans=max(ans, a[i+1]-a[i]);
return ans;
}
ll solve2(int n) {
ll lf, rf; MinMax(0, INF, &lf, &rf);
ll d=1, p=lf, ans=1;
while (p < rf) {
ll dcp=d;
ll mn=-1, mx=-1;
while (mn == -1) {
MinMax(p+1, p+dcp+1, &mn, &mx);
if (mn == -1) dcp*=2;
}
ans=max(ans, mn-p), d=ans;
p=mx;
if (rf-p <= d) break;
} return ans;
}
ll findGap(int t, int n) {
if (t == 1) return solve1(n);
return solve2(n);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is 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 |
0 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2644 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2644 KB |
Output is correct |
16 |
Correct |
8 ms |
2580 KB |
Output is correct |
17 |
Correct |
8 ms |
2584 KB |
Output is correct |
18 |
Correct |
8 ms |
2588 KB |
Output is correct |
19 |
Correct |
8 ms |
2580 KB |
Output is correct |
20 |
Correct |
7 ms |
2648 KB |
Output is correct |
21 |
Correct |
30 ms |
3620 KB |
Output is correct |
22 |
Correct |
30 ms |
3544 KB |
Output is correct |
23 |
Correct |
30 ms |
3624 KB |
Output is correct |
24 |
Correct |
30 ms |
3620 KB |
Output is correct |
25 |
Correct |
28 ms |
3624 KB |
Output is correct |
26 |
Correct |
32 ms |
3636 KB |
Output is correct |
27 |
Correct |
32 ms |
3644 KB |
Output is correct |
28 |
Correct |
32 ms |
3592 KB |
Output is correct |
29 |
Correct |
33 ms |
3620 KB |
Output is correct |
30 |
Correct |
26 ms |
3640 KB |
Output is correct |
31 |
Correct |
0 ms |
2392 KB |
Output is correct |
32 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
2 |
Partially correct |
0 ms |
2392 KB |
Partially correct |
3 |
Partially correct |
0 ms |
2392 KB |
Partially correct |
4 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
5 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
16 |
Correct |
5 ms |
2584 KB |
Output is correct |
17 |
Correct |
5 ms |
2820 KB |
Output is correct |
18 |
Correct |
5 ms |
2584 KB |
Output is correct |
19 |
Correct |
5 ms |
2576 KB |
Output is correct |
20 |
Correct |
4 ms |
2824 KB |
Output is correct |
21 |
Correct |
19 ms |
2856 KB |
Output is correct |
22 |
Correct |
19 ms |
2848 KB |
Output is correct |
23 |
Correct |
19 ms |
2844 KB |
Output is correct |
24 |
Correct |
19 ms |
2860 KB |
Output is correct |
25 |
Partially correct |
39 ms |
2852 KB |
Partially correct |
26 |
Correct |
19 ms |
2856 KB |
Output is correct |
27 |
Correct |
19 ms |
2860 KB |
Output is correct |
28 |
Correct |
20 ms |
3080 KB |
Output is correct |
29 |
Correct |
19 ms |
2852 KB |
Output is correct |
30 |
Correct |
17 ms |
2720 KB |
Output is correct |
31 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
32 |
Correct |
1 ms |
2392 KB |
Output is correct |