#include "gap.h"
#include <cstdio>
#include <algorithm>
#define X first
#define Y second
#define PB push_back
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll OO = 1e18;
int cnt = 0;
pll query(ll a, ll b) {
if(a > b) { return {-1, -1}; }
ll ret, ret_;
++cnt;
MinMax(a, b, &ret, &ret_);
return {ret, ret_};
}
ll solve(ll lst, ll l, ll r, int n) {
if(n == 1) { return 0; }
pll res = query(l, l + (r - l) / (n - 1));
pll res2 = query(res.X + 1, res.Y - 1);
ll ret = res.X - lst;
if(res2.X == -1) {
ret = max(ret, res.Y - res.X);
}
return ret = max(ret, solve(max(lst, res.Y), l + (r - l) / (n - 1) + 1, r, n - 1));
}
ll findGap(int T, int n) {
cnt = 0;
pll res = query(0, OO);
ll ret = solve(res.X, res.X + 1, res.Y, n);
if(cnt > 3 * n) { return -1; }
return ret;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
600 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
13 |
Incorrect |
2 ms |
600 KB |
Output isn't correct |
14 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
15 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
16 |
Incorrect |
13 ms |
3160 KB |
Output isn't correct |
17 |
Incorrect |
16 ms |
3160 KB |
Output isn't correct |
18 |
Incorrect |
19 ms |
3160 KB |
Output isn't correct |
19 |
Incorrect |
12 ms |
3160 KB |
Output isn't correct |
20 |
Incorrect |
7 ms |
3160 KB |
Output isn't correct |
21 |
Incorrect |
55 ms |
12040 KB |
Output isn't correct |
22 |
Incorrect |
50 ms |
11980 KB |
Output isn't correct |
23 |
Incorrect |
69 ms |
12120 KB |
Output isn't correct |
24 |
Incorrect |
54 ms |
12116 KB |
Output isn't correct |
25 |
Incorrect |
45 ms |
12124 KB |
Output isn't correct |
26 |
Incorrect |
49 ms |
12028 KB |
Output isn't correct |
27 |
Incorrect |
47 ms |
12108 KB |
Output isn't correct |
28 |
Incorrect |
67 ms |
11920 KB |
Output isn't correct |
29 |
Incorrect |
63 ms |
11920 KB |
Output isn't correct |
30 |
Incorrect |
30 ms |
12064 KB |
Output isn't correct |
31 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
32 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Partially correct |
0 ms |
344 KB |
Partially correct |
3 |
Partially correct |
0 ms |
344 KB |
Partially correct |
4 |
Partially correct |
0 ms |
344 KB |
Partially correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Partially correct |
0 ms |
344 KB |
Partially correct |
7 |
Partially correct |
0 ms |
344 KB |
Partially correct |
8 |
Partially correct |
1 ms |
344 KB |
Partially correct |
9 |
Partially correct |
0 ms |
344 KB |
Partially correct |
10 |
Partially correct |
0 ms |
344 KB |
Partially correct |
11 |
Partially correct |
1 ms |
600 KB |
Partially correct |
12 |
Partially correct |
1 ms |
600 KB |
Partially correct |
13 |
Partially correct |
1 ms |
600 KB |
Partially correct |
14 |
Partially correct |
1 ms |
600 KB |
Partially correct |
15 |
Correct |
1 ms |
600 KB |
Output is correct |
16 |
Partially correct |
11 ms |
3160 KB |
Partially correct |
17 |
Partially correct |
11 ms |
3160 KB |
Partially correct |
18 |
Partially correct |
11 ms |
3160 KB |
Partially correct |
19 |
Partially correct |
10 ms |
3160 KB |
Partially correct |
20 |
Partially correct |
8 ms |
3180 KB |
Partially correct |
21 |
Partially correct |
53 ms |
12024 KB |
Partially correct |
22 |
Partially correct |
46 ms |
12096 KB |
Partially correct |
23 |
Partially correct |
67 ms |
12112 KB |
Partially correct |
24 |
Partially correct |
58 ms |
11928 KB |
Partially correct |
25 |
Correct |
40 ms |
11928 KB |
Output is correct |
26 |
Partially correct |
54 ms |
12016 KB |
Partially correct |
27 |
Partially correct |
49 ms |
12116 KB |
Partially correct |
28 |
Partially correct |
60 ms |
12112 KB |
Partially correct |
29 |
Partially correct |
57 ms |
11980 KB |
Partially correct |
30 |
Partially correct |
53 ms |
12084 KB |
Partially correct |
31 |
Partially correct |
1 ms |
344 KB |
Partially correct |
32 |
Partially correct |
0 ms |
344 KB |
Partially correct |