Submission #47780

# Submission time Handle Problem Language Result Execution time Memory
47780 2018-05-07T08:25:05 Z ikura355 Gap (APIO16_gap) C++14
100 / 100
71 ms 2156 KB
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int maxn = 1e5 + 5;
const ll inf = 2e18;

ll a[maxn];

ll findGap(int T, int N) {
    if(T==1) {
        ll L = -inf, R = inf;
        for(int i=1,j=N;i<=j;i++,j--) {
            MinMax(L+1,R-1,&L,&R);
            a[i] = L; a[j] = R;
        }
        ll ans = 0;
        for(int i=1;i<N;i++) ans = max(ans, a[i+1]-a[i]);
        return ans;
    }
    else {
        ll L, R;
        MinMax(-inf,inf,&L,&R);
        ll sz = (ll)ceil((double)(R-L-1)/(N-1));
        ll ans = 0, last = L;
        for(ll x=L+1;x<=R-1;x+=sz) {
            ll t1, t2;
            MinMax(x,min(R-1,x+sz-1),&t1,&t2);
            if(t1==-1) continue;
            ans = max(ans, t1-last);
            last = t2;
        }
        ans = max(ans, R-last);
        return ans;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 2 ms 564 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 2 ms 680 KB Output is correct
7 Correct 2 ms 680 KB Output is correct
8 Correct 2 ms 680 KB Output is correct
9 Correct 2 ms 680 KB Output is correct
10 Correct 2 ms 680 KB Output is correct
11 Correct 2 ms 680 KB Output is correct
12 Correct 2 ms 680 KB Output is correct
13 Correct 3 ms 680 KB Output is correct
14 Correct 2 ms 680 KB Output is correct
15 Correct 2 ms 680 KB Output is correct
16 Correct 14 ms 952 KB Output is correct
17 Correct 14 ms 952 KB Output is correct
18 Correct 15 ms 952 KB Output is correct
19 Correct 15 ms 1008 KB Output is correct
20 Correct 11 ms 1008 KB Output is correct
21 Correct 54 ms 2152 KB Output is correct
22 Correct 53 ms 2156 KB Output is correct
23 Correct 53 ms 2156 KB Output is correct
24 Correct 54 ms 2156 KB Output is correct
25 Correct 46 ms 2156 KB Output is correct
26 Correct 53 ms 2156 KB Output is correct
27 Correct 54 ms 2156 KB Output is correct
28 Correct 54 ms 2156 KB Output is correct
29 Correct 53 ms 2156 KB Output is correct
30 Correct 39 ms 2156 KB Output is correct
31 Correct 2 ms 2156 KB Output is correct
32 Correct 2 ms 2156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2156 KB Output is correct
2 Correct 2 ms 2156 KB Output is correct
3 Correct 2 ms 2156 KB Output is correct
4 Correct 2 ms 2156 KB Output is correct
5 Correct 2 ms 2156 KB Output is correct
6 Correct 2 ms 2156 KB Output is correct
7 Correct 2 ms 2156 KB Output is correct
8 Correct 2 ms 2156 KB Output is correct
9 Correct 2 ms 2156 KB Output is correct
10 Correct 2 ms 2156 KB Output is correct
11 Correct 3 ms 2156 KB Output is correct
12 Correct 3 ms 2156 KB Output is correct
13 Correct 3 ms 2156 KB Output is correct
14 Correct 3 ms 2156 KB Output is correct
15 Correct 2 ms 2156 KB Output is correct
16 Correct 19 ms 2156 KB Output is correct
17 Correct 19 ms 2156 KB Output is correct
18 Correct 18 ms 2156 KB Output is correct
19 Correct 18 ms 2156 KB Output is correct
20 Correct 9 ms 2156 KB Output is correct
21 Correct 71 ms 2156 KB Output is correct
22 Correct 71 ms 2156 KB Output is correct
23 Correct 71 ms 2156 KB Output is correct
24 Correct 71 ms 2156 KB Output is correct
25 Correct 66 ms 2156 KB Output is correct
26 Correct 71 ms 2156 KB Output is correct
27 Correct 71 ms 2156 KB Output is correct
28 Correct 71 ms 2156 KB Output is correct
29 Correct 71 ms 2156 KB Output is correct
30 Correct 39 ms 2156 KB Output is correct
31 Correct 2 ms 2156 KB Output is correct
32 Correct 2 ms 2156 KB Output is correct