# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
371447 |
2021-02-26T15:50:21 Z |
Sorting |
Gap (APIO16_gap) |
C++17 |
|
70 ms |
1288 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using namespace std;
mt19937 mt(2);
void check_max(ll &a, ll b){ a = (b > a) ? b : a; }
const ll INF = 1e18;
int t, n;
ll solve_1(){
ll l, r, ans = 0;
MinMax(0, INF, &l, &r);
ll l2, r2;
n -= 2;
while(n > 0){
MinMax(l + 1, r - 1, &l2, &r2);
ans = max(ans, max(l2 - l, r - r2));
l = l2, r = r2;
n -= 2;
}
ans = max(ans, r - l);
return ans;
}
ll findGap(int _t, int _n){
t = _t, n = _n;
if(t == 1) return solve_1();
if(n <= 1) return 0;
ll l, r;
MinMax(0, INF, &l, &r);
ll bound = ((r - l) / (n - 1)) + !!((r - l) % (n - 1)), ans = bound;
ll prev = l;
for(ll i = l; i < r; i += bound + 1){
ll l2, r2;
MinMax(i, i + bound, &l2, &r2);
if(l2 != -1){
check_max(ans, l2 - prev);
prev = r2;
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
11 ms |
492 KB |
Output is correct |
17 |
Correct |
11 ms |
492 KB |
Output is correct |
18 |
Correct |
11 ms |
492 KB |
Output is correct |
19 |
Correct |
11 ms |
492 KB |
Output is correct |
20 |
Correct |
8 ms |
492 KB |
Output is correct |
21 |
Correct |
43 ms |
1260 KB |
Output is correct |
22 |
Correct |
44 ms |
1132 KB |
Output is correct |
23 |
Correct |
42 ms |
1132 KB |
Output is correct |
24 |
Correct |
51 ms |
1132 KB |
Output is correct |
25 |
Correct |
37 ms |
1132 KB |
Output is correct |
26 |
Correct |
42 ms |
1132 KB |
Output is correct |
27 |
Correct |
42 ms |
1192 KB |
Output is correct |
28 |
Correct |
45 ms |
1288 KB |
Output is correct |
29 |
Correct |
48 ms |
1132 KB |
Output is correct |
30 |
Correct |
37 ms |
1132 KB |
Output is correct |
31 |
Correct |
1 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
0 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
14 ms |
492 KB |
Output is correct |
17 |
Correct |
14 ms |
492 KB |
Output is correct |
18 |
Correct |
17 ms |
492 KB |
Output is correct |
19 |
Correct |
14 ms |
492 KB |
Output is correct |
20 |
Correct |
7 ms |
492 KB |
Output is correct |
21 |
Correct |
58 ms |
1132 KB |
Output is correct |
22 |
Correct |
60 ms |
1132 KB |
Output is correct |
23 |
Correct |
58 ms |
1132 KB |
Output is correct |
24 |
Correct |
59 ms |
1132 KB |
Output is correct |
25 |
Correct |
54 ms |
1132 KB |
Output is correct |
26 |
Correct |
59 ms |
1260 KB |
Output is correct |
27 |
Correct |
57 ms |
1132 KB |
Output is correct |
28 |
Correct |
58 ms |
1132 KB |
Output is correct |
29 |
Correct |
70 ms |
1260 KB |
Output is correct |
30 |
Correct |
30 ms |
1132 KB |
Output is correct |
31 |
Correct |
1 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
364 KB |
Output is correct |