#include "gap.h"
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll MIN = 0, MAX = 1000000000000000000;
ll solve1(int n) {
ll v[n+1];
int i = 1, k = n;
ll mn = MIN, mx = MAX;
while (i <= k) {
MinMax(mn, mx, v+i, v+k);
mn = v[i++]+1;
mx = v[k--]-1;
}
ll ret = 1;
for (int i = 1; i < n; i++)
ret = max(ret, v[i+1] - v[i]);
return ret;
}
ll solve2(int n) {
ll cur, lim;
MinMax(MIN, MAX, &cur, &lim);
ll ans = 1, test, l, r;
while (cur < lim) {
test = 0;
do MinMax(cur+1+test*ans, cur+1+(test+1)*ans, &l, &r), test++;
while (l == -1);
ans = max(ans, l - cur);
cur = r;
}
return ans;
}
ll findGap(int t, int n)
{
return t == 1 ? solve1(n) : solve2(n);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4240 KB |
Output is correct |
2 |
Correct |
0 ms |
4240 KB |
Output is correct |
3 |
Correct |
0 ms |
4240 KB |
Output is correct |
4 |
Correct |
0 ms |
4240 KB |
Output is correct |
5 |
Correct |
0 ms |
4240 KB |
Output is correct |
6 |
Correct |
0 ms |
4240 KB |
Output is correct |
7 |
Correct |
0 ms |
4240 KB |
Output is correct |
8 |
Correct |
0 ms |
4240 KB |
Output is correct |
9 |
Correct |
0 ms |
4240 KB |
Output is correct |
10 |
Correct |
0 ms |
4240 KB |
Output is correct |
11 |
Correct |
0 ms |
4240 KB |
Output is correct |
12 |
Correct |
0 ms |
4240 KB |
Output is correct |
13 |
Correct |
0 ms |
4240 KB |
Output is correct |
14 |
Correct |
0 ms |
4240 KB |
Output is correct |
15 |
Correct |
0 ms |
4240 KB |
Output is correct |
16 |
Correct |
13 ms |
4312 KB |
Output is correct |
17 |
Correct |
13 ms |
4312 KB |
Output is correct |
18 |
Correct |
9 ms |
4308 KB |
Output is correct |
19 |
Correct |
9 ms |
4308 KB |
Output is correct |
20 |
Correct |
9 ms |
4308 KB |
Output is correct |
21 |
Correct |
59 ms |
4896 KB |
Output is correct |
22 |
Correct |
49 ms |
4892 KB |
Output is correct |
23 |
Correct |
59 ms |
4900 KB |
Output is correct |
24 |
Correct |
59 ms |
4892 KB |
Output is correct |
25 |
Correct |
53 ms |
4892 KB |
Output is correct |
26 |
Correct |
53 ms |
4892 KB |
Output is correct |
27 |
Correct |
59 ms |
4892 KB |
Output is correct |
28 |
Correct |
59 ms |
4892 KB |
Output is correct |
29 |
Correct |
59 ms |
4896 KB |
Output is correct |
30 |
Correct |
39 ms |
4896 KB |
Output is correct |
31 |
Correct |
0 ms |
4240 KB |
Output is correct |
32 |
Correct |
0 ms |
4240 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
2 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
3 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
4 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
5 |
Partially correct |
73 ms |
4240 KB |
Partially correct |
6 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
7 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
8 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
9 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
10 |
Partially correct |
39 ms |
4240 KB |
Partially correct |
11 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
12 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
13 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
14 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
15 |
Partially correct |
239 ms |
4240 KB |
Partially correct |
16 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
17 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
18 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
19 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
20 |
Partially correct |
83 ms |
4240 KB |
Partially correct |
21 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
22 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
23 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
24 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
25 |
Partially correct |
446 ms |
4240 KB |
Partially correct |
26 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
27 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
28 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
29 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |
30 |
Partially correct |
126 ms |
4240 KB |
Partially correct |
31 |
Partially correct |
0 ms |
4240 KB |
Partially correct |
32 |
Execution timed out |
2000 ms |
4240 KB |
Execution timed out |