# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
68215 |
2018-08-16T08:35:27 Z |
gusfring |
Gap (APIO16_gap) |
C++14 |
|
92 ms |
2284 KB |
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
const int MAXN = 1e5 + 5;
typedef long long ll;
ll A[MAXN], res, mn, mx;
ll findGap2(int T, int N){
MinMax(0, 1e18, &A[1], &A[N]);
for(int i=2, j=N-1; i<=j; ++i, --j) MinMax(A[i - 1] + 1, A[j + 1] - 1, &A[i], &A[j]);
for(int i=2; i<=N; i++) res = max(res, A[i] - A[i - 1]);
return res;
}
ll solve(ll lo, ll hi){
if(lo >= hi || hi - lo <= res) return 0;
unsigned long long x = (1LLU * lo + hi) / 2;
ll mid = (ll)(x), mn1 = -1, mx1 = -1, mn2 = -1, mx2 = -1;
if(lo < mid) MinMax(lo, mid, &mn1, &mx1);
if(mid + 1 < hi) MinMax(mid + 1, hi, &mn2, &mx2);
ll r = 0, r1 = 0, r2 = 0;
if(mx1 != -1 && mx2 != -1) r = mn2 - mx1;
if(mx2 != -1 && mx2 != mn2) r2 = solve(mn2, mx2);
if(mx1 != -1 && mx1 != mn1) r1 = solve(mn1, mx1);
res = max({res, r, r1, r2});
return res;
}
long long findGap(int T, int N){
if(T == 2){
MinMax(0, 1e18, &mn, &mx);
return solve(mn, mx);
}
return findGap2(T, N);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
4 ms |
540 KB |
Output is correct |
4 |
Correct |
4 ms |
556 KB |
Output is correct |
5 |
Correct |
3 ms |
556 KB |
Output is correct |
6 |
Correct |
3 ms |
640 KB |
Output is correct |
7 |
Correct |
2 ms |
640 KB |
Output is correct |
8 |
Correct |
2 ms |
640 KB |
Output is correct |
9 |
Correct |
2 ms |
640 KB |
Output is correct |
10 |
Correct |
3 ms |
640 KB |
Output is correct |
11 |
Correct |
3 ms |
640 KB |
Output is correct |
12 |
Correct |
3 ms |
640 KB |
Output is correct |
13 |
Correct |
4 ms |
640 KB |
Output is correct |
14 |
Correct |
4 ms |
640 KB |
Output is correct |
15 |
Correct |
3 ms |
640 KB |
Output is correct |
16 |
Correct |
16 ms |
980 KB |
Output is correct |
17 |
Correct |
16 ms |
1008 KB |
Output is correct |
18 |
Correct |
17 ms |
1008 KB |
Output is correct |
19 |
Correct |
17 ms |
1008 KB |
Output is correct |
20 |
Correct |
13 ms |
1008 KB |
Output is correct |
21 |
Correct |
59 ms |
2284 KB |
Output is correct |
22 |
Correct |
66 ms |
2284 KB |
Output is correct |
23 |
Correct |
55 ms |
2284 KB |
Output is correct |
24 |
Correct |
55 ms |
2284 KB |
Output is correct |
25 |
Correct |
50 ms |
2284 KB |
Output is correct |
26 |
Correct |
55 ms |
2284 KB |
Output is correct |
27 |
Correct |
60 ms |
2284 KB |
Output is correct |
28 |
Correct |
71 ms |
2284 KB |
Output is correct |
29 |
Correct |
56 ms |
2284 KB |
Output is correct |
30 |
Correct |
43 ms |
2284 KB |
Output is correct |
31 |
Correct |
2 ms |
2284 KB |
Output is correct |
32 |
Correct |
2 ms |
2284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
3 ms |
2284 KB |
Partially correct |
2 |
Partially correct |
2 ms |
2284 KB |
Partially correct |
3 |
Partially correct |
2 ms |
2284 KB |
Partially correct |
4 |
Partially correct |
2 ms |
2284 KB |
Partially correct |
5 |
Partially correct |
2 ms |
2284 KB |
Partially correct |
6 |
Partially correct |
2 ms |
2284 KB |
Partially correct |
7 |
Partially correct |
2 ms |
2284 KB |
Partially correct |
8 |
Partially correct |
2 ms |
2284 KB |
Partially correct |
9 |
Partially correct |
2 ms |
2284 KB |
Partially correct |
10 |
Partially correct |
3 ms |
2284 KB |
Partially correct |
11 |
Partially correct |
3 ms |
2284 KB |
Partially correct |
12 |
Partially correct |
3 ms |
2284 KB |
Partially correct |
13 |
Partially correct |
4 ms |
2284 KB |
Partially correct |
14 |
Partially correct |
3 ms |
2284 KB |
Partially correct |
15 |
Partially correct |
3 ms |
2284 KB |
Partially correct |
16 |
Partially correct |
17 ms |
2284 KB |
Partially correct |
17 |
Partially correct |
14 ms |
2284 KB |
Partially correct |
18 |
Partially correct |
13 ms |
2284 KB |
Partially correct |
19 |
Partially correct |
18 ms |
2284 KB |
Partially correct |
20 |
Partially correct |
13 ms |
2284 KB |
Partially correct |
21 |
Partially correct |
43 ms |
2284 KB |
Partially correct |
22 |
Partially correct |
45 ms |
2284 KB |
Partially correct |
23 |
Partially correct |
49 ms |
2284 KB |
Partially correct |
24 |
Partially correct |
43 ms |
2284 KB |
Partially correct |
25 |
Partially correct |
92 ms |
2284 KB |
Partially correct |
26 |
Partially correct |
59 ms |
2284 KB |
Partially correct |
27 |
Partially correct |
43 ms |
2284 KB |
Partially correct |
28 |
Partially correct |
47 ms |
2284 KB |
Partially correct |
29 |
Partially correct |
47 ms |
2284 KB |
Partially correct |
30 |
Partially correct |
51 ms |
2284 KB |
Partially correct |
31 |
Partially correct |
3 ms |
2284 KB |
Partially correct |
32 |
Partially correct |
3 ms |
2284 KB |
Partially correct |