# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
68205 |
2018-08-16T08:17:35 Z |
gusfring |
Gap (APIO16_gap) |
C++14 |
|
167 ms |
2240 KB |
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
const int MAXN = 1e5 + 5;
typedef long long ll;
long long A[MAXN], res;
long long 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 mn, mx;
ll solve(ll lo, ll hi){
if(lo >= hi) 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 res = 0, r1 = 0, r2 = 0;
if(mx1 != -1 && mx2 != -1) res = mn2 - mx1;
if(mx2 != -1 && mx2 != mn2) r2 = solve(mn2, mx2);
if(mx1 != -1 && mx1 != mn1) r1 = solve(mn1, mx1);
return max({res, r1, r2});
}
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 |
476 KB |
Output is correct |
3 |
Correct |
2 ms |
476 KB |
Output is correct |
4 |
Correct |
2 ms |
476 KB |
Output is correct |
5 |
Correct |
3 ms |
636 KB |
Output is correct |
6 |
Correct |
2 ms |
636 KB |
Output is correct |
7 |
Correct |
2 ms |
636 KB |
Output is correct |
8 |
Correct |
3 ms |
704 KB |
Output is correct |
9 |
Correct |
2 ms |
704 KB |
Output is correct |
10 |
Correct |
2 ms |
704 KB |
Output is correct |
11 |
Correct |
3 ms |
704 KB |
Output is correct |
12 |
Correct |
3 ms |
704 KB |
Output is correct |
13 |
Correct |
4 ms |
704 KB |
Output is correct |
14 |
Correct |
4 ms |
704 KB |
Output is correct |
15 |
Correct |
3 ms |
704 KB |
Output is correct |
16 |
Correct |
16 ms |
1004 KB |
Output is correct |
17 |
Correct |
16 ms |
1004 KB |
Output is correct |
18 |
Correct |
17 ms |
1116 KB |
Output is correct |
19 |
Correct |
18 ms |
1116 KB |
Output is correct |
20 |
Correct |
12 ms |
1116 KB |
Output is correct |
21 |
Correct |
56 ms |
2236 KB |
Output is correct |
22 |
Correct |
65 ms |
2236 KB |
Output is correct |
23 |
Correct |
63 ms |
2240 KB |
Output is correct |
24 |
Correct |
147 ms |
2240 KB |
Output is correct |
25 |
Correct |
57 ms |
2240 KB |
Output is correct |
26 |
Correct |
60 ms |
2240 KB |
Output is correct |
27 |
Correct |
62 ms |
2240 KB |
Output is correct |
28 |
Correct |
64 ms |
2240 KB |
Output is correct |
29 |
Correct |
63 ms |
2240 KB |
Output is correct |
30 |
Correct |
42 ms |
2240 KB |
Output is correct |
31 |
Correct |
3 ms |
2240 KB |
Output is correct |
32 |
Correct |
3 ms |
2240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
2240 KB |
Partially correct |
2 |
Partially correct |
2 ms |
2240 KB |
Partially correct |
3 |
Partially correct |
3 ms |
2240 KB |
Partially correct |
4 |
Partially correct |
2 ms |
2240 KB |
Partially correct |
5 |
Partially correct |
2 ms |
2240 KB |
Partially correct |
6 |
Partially correct |
2 ms |
2240 KB |
Partially correct |
7 |
Partially correct |
2 ms |
2240 KB |
Partially correct |
8 |
Partially correct |
2 ms |
2240 KB |
Partially correct |
9 |
Partially correct |
2 ms |
2240 KB |
Partially correct |
10 |
Partially correct |
3 ms |
2240 KB |
Partially correct |
11 |
Partially correct |
4 ms |
2240 KB |
Partially correct |
12 |
Partially correct |
5 ms |
2240 KB |
Partially correct |
13 |
Partially correct |
4 ms |
2240 KB |
Partially correct |
14 |
Partially correct |
4 ms |
2240 KB |
Partially correct |
15 |
Partially correct |
3 ms |
2240 KB |
Partially correct |
16 |
Partially correct |
42 ms |
2240 KB |
Partially correct |
17 |
Partially correct |
43 ms |
2240 KB |
Partially correct |
18 |
Partially correct |
35 ms |
2240 KB |
Partially correct |
19 |
Partially correct |
34 ms |
2240 KB |
Partially correct |
20 |
Partially correct |
19 ms |
2240 KB |
Partially correct |
21 |
Partially correct |
143 ms |
2240 KB |
Partially correct |
22 |
Partially correct |
135 ms |
2240 KB |
Partially correct |
23 |
Partially correct |
128 ms |
2240 KB |
Partially correct |
24 |
Partially correct |
167 ms |
2240 KB |
Partially correct |
25 |
Partially correct |
133 ms |
2240 KB |
Partially correct |
26 |
Partially correct |
140 ms |
2240 KB |
Partially correct |
27 |
Partially correct |
156 ms |
2240 KB |
Partially correct |
28 |
Partially correct |
135 ms |
2240 KB |
Partially correct |
29 |
Partially correct |
143 ms |
2240 KB |
Partially correct |
30 |
Partially correct |
79 ms |
2240 KB |
Partially correct |
31 |
Partially correct |
2 ms |
2240 KB |
Partially correct |
32 |
Partially correct |
2 ms |
2240 KB |
Partially correct |