# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
221380 |
2020-04-10T00:48:24 Z |
zoooma13 |
Gap (APIO16_gap) |
C++14 |
|
79 ms |
2096 KB |
#include "bits/stdc++.h"
#include "gap.h"
using namespace std;
long long findGap(int T, int N){
if(N <= 8 || T == 1){
vector <long long> A(N);
MinMax(0 ,1e18 ,&A[0] ,&A[N-1]);
for(int i=1; i<(N+1)/2; i++)
MinMax(A[i-1]+1 ,A[N-i]-1 ,&A[i] ,&A[N-i-1]);
long long ret = 1;
for(int i=1; i<N; i++)
ret = max(ret ,A[i]-A[i-1]);
return ret;
}
long long mn ,mx ,mx_dist = 1 ,s ,t;
MinMax(0 ,1e18 ,&mn ,&mx);
long long d = (mx-mn)/(N-1) ,fh = (mx-mn)%(N-1) ,lst = mn;
vector <long long> rngs(N ,0);
rngs[0] = mn;
for(int i=1; i<N; i++)
rngs[i] += (i <= fh) + rngs[i-1] + d;
for(int i=0; i<N-1; i++){
MinMax(rngs[i] ,rngs[i+1]-1 ,&s ,&t);
if(s != -1){
mx_dist = max(mx_dist ,s-lst);
lst = t;
}
}
return max(mx-lst ,mx_dist);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
16 ms |
768 KB |
Output is correct |
17 |
Correct |
16 ms |
768 KB |
Output is correct |
18 |
Correct |
19 ms |
768 KB |
Output is correct |
19 |
Correct |
16 ms |
768 KB |
Output is correct |
20 |
Correct |
13 ms |
768 KB |
Output is correct |
21 |
Correct |
62 ms |
1952 KB |
Output is correct |
22 |
Correct |
53 ms |
1900 KB |
Output is correct |
23 |
Correct |
54 ms |
1912 KB |
Output is correct |
24 |
Correct |
61 ms |
1908 KB |
Output is correct |
25 |
Correct |
48 ms |
2096 KB |
Output is correct |
26 |
Correct |
54 ms |
1916 KB |
Output is correct |
27 |
Correct |
54 ms |
1912 KB |
Output is correct |
28 |
Correct |
53 ms |
1864 KB |
Output is correct |
29 |
Correct |
56 ms |
1860 KB |
Output is correct |
30 |
Correct |
40 ms |
1920 KB |
Output is correct |
31 |
Correct |
5 ms |
384 KB |
Output is correct |
32 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
6 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
22 ms |
768 KB |
Output is correct |
17 |
Correct |
20 ms |
768 KB |
Output is correct |
18 |
Correct |
20 ms |
768 KB |
Output is correct |
19 |
Correct |
20 ms |
768 KB |
Output is correct |
20 |
Correct |
13 ms |
768 KB |
Output is correct |
21 |
Correct |
68 ms |
1912 KB |
Output is correct |
22 |
Correct |
69 ms |
1860 KB |
Output is correct |
23 |
Correct |
69 ms |
1912 KB |
Output is correct |
24 |
Correct |
79 ms |
1912 KB |
Output is correct |
25 |
Correct |
62 ms |
1964 KB |
Output is correct |
26 |
Correct |
71 ms |
1872 KB |
Output is correct |
27 |
Correct |
79 ms |
1912 KB |
Output is correct |
28 |
Correct |
69 ms |
1888 KB |
Output is correct |
29 |
Correct |
70 ms |
1864 KB |
Output is correct |
30 |
Correct |
40 ms |
1912 KB |
Output is correct |
31 |
Correct |
4 ms |
384 KB |
Output is correct |
32 |
Correct |
4 ms |
384 KB |
Output is correct |