#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, sz;
long long a[N];
long long s = 0, t = 1e18;
long long mn, mx;
long long solve1() {
for (int i = 1; i <= (n + 1) / 2; ++i) {
if (s <= t) MinMax(s, t, &mn, &mx);
a[i] = mn; a[n - i + 1] = mx;
s = mn + 1, t = mx - 1;
}
sz = n;
}
long long solve2() {
MinMax(s, t, &s, &t);
long long gap = (t - s + n - 2) / (n - 1);
for (long long i = s; i <= t; i += gap + 1) {
MinMax(i, i + gap, &mn, &mx);
a[++sz] = mn;
a[++sz] = mx;
}
}
long long findGap(int T, int _N) {
n = _N;
if (T == 1) solve1();
else solve2();
long long ans = 0;
for (int i = 2; i <= sz; ++i) ans = max(ans, a[i] - a[i-1]);
return ans;
}
Compilation message
gap.cpp: In function 'long long int solve1()':
gap.cpp:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
gap.cpp: In function 'long long int solve2()':
gap.cpp:28:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5920 KB |
Output is correct |
2 |
Correct |
0 ms |
5920 KB |
Output is correct |
3 |
Correct |
0 ms |
5920 KB |
Output is correct |
4 |
Correct |
0 ms |
5920 KB |
Output is correct |
5 |
Correct |
0 ms |
5920 KB |
Output is correct |
6 |
Correct |
0 ms |
5920 KB |
Output is correct |
7 |
Correct |
0 ms |
5920 KB |
Output is correct |
8 |
Correct |
0 ms |
5920 KB |
Output is correct |
9 |
Correct |
0 ms |
5920 KB |
Output is correct |
10 |
Correct |
0 ms |
5920 KB |
Output is correct |
11 |
Correct |
0 ms |
5920 KB |
Output is correct |
12 |
Correct |
0 ms |
5920 KB |
Output is correct |
13 |
Correct |
0 ms |
5920 KB |
Output is correct |
14 |
Correct |
0 ms |
5920 KB |
Output is correct |
15 |
Correct |
0 ms |
5920 KB |
Output is correct |
16 |
Correct |
13 ms |
5920 KB |
Output is correct |
17 |
Correct |
13 ms |
5920 KB |
Output is correct |
18 |
Correct |
13 ms |
5920 KB |
Output is correct |
19 |
Correct |
13 ms |
5920 KB |
Output is correct |
20 |
Correct |
6 ms |
5920 KB |
Output is correct |
21 |
Correct |
59 ms |
5920 KB |
Output is correct |
22 |
Correct |
69 ms |
5920 KB |
Output is correct |
23 |
Correct |
53 ms |
5920 KB |
Output is correct |
24 |
Correct |
56 ms |
5920 KB |
Output is correct |
25 |
Correct |
49 ms |
5920 KB |
Output is correct |
26 |
Correct |
59 ms |
5920 KB |
Output is correct |
27 |
Correct |
53 ms |
5920 KB |
Output is correct |
28 |
Correct |
59 ms |
5920 KB |
Output is correct |
29 |
Correct |
53 ms |
5920 KB |
Output is correct |
30 |
Correct |
43 ms |
5920 KB |
Output is correct |
31 |
Correct |
0 ms |
5920 KB |
Output is correct |
32 |
Correct |
0 ms |
5920 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5920 KB |
Output is correct |
2 |
Incorrect |
0 ms |
5920 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
5920 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
5920 KB |
Output isn't correct |
5 |
Correct |
0 ms |
5920 KB |
Output is correct |
6 |
Incorrect |
0 ms |
5920 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
5920 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
5920 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
5920 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
5920 KB |
Output isn't correct |
11 |
Incorrect |
0 ms |
5920 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
5920 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
5920 KB |
Output isn't correct |
14 |
Incorrect |
0 ms |
5920 KB |
Output isn't correct |
15 |
Correct |
0 ms |
5920 KB |
Output is correct |
16 |
Incorrect |
19 ms |
5920 KB |
Output isn't correct |
17 |
Incorrect |
13 ms |
5920 KB |
Output isn't correct |
18 |
Incorrect |
16 ms |
5920 KB |
Output isn't correct |
19 |
Incorrect |
16 ms |
5920 KB |
Output isn't correct |
20 |
Incorrect |
6 ms |
5920 KB |
Output isn't correct |
21 |
Runtime error |
43 ms |
5920 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
22 |
Runtime error |
43 ms |
5920 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
23 |
Incorrect |
66 ms |
5920 KB |
Output isn't correct |
24 |
Runtime error |
43 ms |
5920 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
25 |
Runtime error |
29 ms |
5920 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
26 |
Runtime error |
53 ms |
5920 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
27 |
Runtime error |
49 ms |
5920 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
28 |
Runtime error |
56 ms |
5920 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
29 |
Runtime error |
49 ms |
5920 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
30 |
Incorrect |
36 ms |
5920 KB |
Output isn't correct |
31 |
Incorrect |
0 ms |
5920 KB |
Output isn't correct |
32 |
Incorrect |
0 ms |
5920 KB |
Output isn't correct |