# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
61124 |
2018-07-25T08:26:29 Z |
Flugan42 |
Gap (APIO16_gap) |
C++14 |
|
95 ms |
2284 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef long double lld;
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define per(i,a,b) for(ll i = a; i >= b; i--)
#define inf 1000000000000000000
#define all(x) x.begin(),x.end()
#define sz(x) (ll)(x).size()
#define trav(a,x) for(auto a : x)
long long findGap(int T, int N)
{
if (T == 1){
vi a; a.assign(N,0);
MinMax(0,inf,&a[0],&a[N-1]);
ll f=1,l=N-2;
while (f<=l){
MinMax(a[f-1]+1,a[l+1]-1,&a[f],&a[l]);
f++; l--;
}
ll best = 0;
rep(i,1,N) if (a[i]-a[i-1] > best) best = a[i]-a[i-1];
return best;
} else {
ll mn,mx,t1,t2;
MinMax(0,inf,&mn,&mx);
vi d; d.assign(N,(mx-mn-1)/N);
rep(i,0,(mx-mn-1)%N) d[i]++;
ll cur = mn+1,gap = 0,best = 0;
rep(i,0,N){
if (d[i] == 0) continue;
MinMax(cur,cur+d[i]-1,&t1,&t2);
if (t1 == -1) gap += d[i];
else {
best = max(best,gap+t1-cur);
gap = cur+d[i]-1-t2;
}
cur += d[i];
}
best = max(best,gap);
return best+1;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
476 KB |
Output is correct |
3 |
Correct |
2 ms |
528 KB |
Output is correct |
4 |
Correct |
3 ms |
528 KB |
Output is correct |
5 |
Correct |
3 ms |
528 KB |
Output is correct |
6 |
Correct |
3 ms |
528 KB |
Output is correct |
7 |
Correct |
4 ms |
568 KB |
Output is correct |
8 |
Correct |
3 ms |
596 KB |
Output is correct |
9 |
Correct |
3 ms |
596 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |
11 |
Correct |
3 ms |
596 KB |
Output is correct |
12 |
Correct |
4 ms |
692 KB |
Output is correct |
13 |
Correct |
4 ms |
692 KB |
Output is correct |
14 |
Correct |
3 ms |
692 KB |
Output is correct |
15 |
Correct |
3 ms |
692 KB |
Output is correct |
16 |
Correct |
24 ms |
1060 KB |
Output is correct |
17 |
Correct |
20 ms |
1060 KB |
Output is correct |
18 |
Correct |
20 ms |
1060 KB |
Output is correct |
19 |
Correct |
18 ms |
1060 KB |
Output is correct |
20 |
Correct |
15 ms |
1060 KB |
Output is correct |
21 |
Correct |
85 ms |
2156 KB |
Output is correct |
22 |
Correct |
74 ms |
2228 KB |
Output is correct |
23 |
Correct |
69 ms |
2228 KB |
Output is correct |
24 |
Correct |
78 ms |
2228 KB |
Output is correct |
25 |
Correct |
62 ms |
2284 KB |
Output is correct |
26 |
Correct |
66 ms |
2284 KB |
Output is correct |
27 |
Correct |
77 ms |
2284 KB |
Output is correct |
28 |
Correct |
62 ms |
2284 KB |
Output is correct |
29 |
Correct |
63 ms |
2284 KB |
Output is correct |
30 |
Correct |
47 ms |
2284 KB |
Output is correct |
31 |
Correct |
3 ms |
2284 KB |
Output is correct |
32 |
Correct |
3 ms |
2284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2284 KB |
Output is correct |
2 |
Correct |
3 ms |
2284 KB |
Output is correct |
3 |
Correct |
2 ms |
2284 KB |
Output is correct |
4 |
Correct |
3 ms |
2284 KB |
Output is correct |
5 |
Correct |
3 ms |
2284 KB |
Output is correct |
6 |
Correct |
2 ms |
2284 KB |
Output is correct |
7 |
Correct |
3 ms |
2284 KB |
Output is correct |
8 |
Correct |
3 ms |
2284 KB |
Output is correct |
9 |
Correct |
3 ms |
2284 KB |
Output is correct |
10 |
Correct |
2 ms |
2284 KB |
Output is correct |
11 |
Correct |
3 ms |
2284 KB |
Output is correct |
12 |
Correct |
3 ms |
2284 KB |
Output is correct |
13 |
Correct |
4 ms |
2284 KB |
Output is correct |
14 |
Correct |
5 ms |
2284 KB |
Output is correct |
15 |
Correct |
4 ms |
2284 KB |
Output is correct |
16 |
Correct |
24 ms |
2284 KB |
Output is correct |
17 |
Correct |
27 ms |
2284 KB |
Output is correct |
18 |
Correct |
26 ms |
2284 KB |
Output is correct |
19 |
Correct |
21 ms |
2284 KB |
Output is correct |
20 |
Correct |
13 ms |
2284 KB |
Output is correct |
21 |
Correct |
84 ms |
2284 KB |
Output is correct |
22 |
Correct |
95 ms |
2284 KB |
Output is correct |
23 |
Correct |
88 ms |
2284 KB |
Output is correct |
24 |
Correct |
88 ms |
2284 KB |
Output is correct |
25 |
Correct |
88 ms |
2284 KB |
Output is correct |
26 |
Correct |
85 ms |
2284 KB |
Output is correct |
27 |
Correct |
90 ms |
2284 KB |
Output is correct |
28 |
Correct |
85 ms |
2284 KB |
Output is correct |
29 |
Correct |
79 ms |
2284 KB |
Output is correct |
30 |
Correct |
48 ms |
2284 KB |
Output is correct |
31 |
Correct |
3 ms |
2284 KB |
Output is correct |
32 |
Correct |
3 ms |
2284 KB |
Output is correct |