Submission #96257

# Submission time Handle Problem Language Result Execution time Memory
96257 2019-02-07T13:15:31 Z xplus2g4 Gap (APIO16_gap) C++11
100 / 100
93 ms 2656 KB
#include <algorithm>
#include "gap.h"
using namespace std;
typedef long long ll;
ll a[200000];
long long findGap(int T, int N){
    ll mn, mx, s=0, t=1e18, ans=1;
    int cnt=0;
    if(T==1){
        ll l=0, r=N-1;
        while(l<=r){
            MinMax(s,t,&mn,&mx);
            a[l++]=mn;
            a[r--]=mx;
            s=mn+1;
            t=mx-1;
        }
        cnt=N;
    } else {
        MinMax(s,t,&mn,&mx);
        ll d=(mx-mn+N-1)/N,x,y;
        a[cnt++]=mn;
        for(s=mn+1, t=s+d; s<mx; s=t+1, t=s+d){
            MinMax(s, min(t, mx-1), &x, &y);
            if (x == -1)
                continue;
            a[cnt++]=x;
            a[cnt++]=y;
        }
        a[cnt++]=mx;
    }
    for(int i=1; i<cnt; i++){
        ans = max(ans, a[i]-a[i-1]);
    }
    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 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 13 ms 760 KB Output is correct
17 Correct 13 ms 760 KB Output is correct
18 Correct 13 ms 760 KB Output is correct
19 Correct 13 ms 760 KB Output is correct
20 Correct 10 ms 760 KB Output is correct
21 Correct 46 ms 1916 KB Output is correct
22 Correct 48 ms 1912 KB Output is correct
23 Correct 48 ms 1912 KB Output is correct
24 Correct 48 ms 1912 KB Output is correct
25 Correct 43 ms 1912 KB Output is correct
26 Correct 46 ms 1912 KB Output is correct
27 Correct 48 ms 1944 KB Output is correct
28 Correct 69 ms 1912 KB Output is correct
29 Correct 65 ms 1912 KB Output is correct
30 Correct 35 ms 1912 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# 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 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 292 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 17 ms 760 KB Output is correct
17 Correct 18 ms 760 KB Output is correct
18 Correct 23 ms 760 KB Output is correct
19 Correct 18 ms 760 KB Output is correct
20 Correct 8 ms 504 KB Output is correct
21 Correct 67 ms 2040 KB Output is correct
22 Correct 65 ms 2040 KB Output is correct
23 Correct 68 ms 2336 KB Output is correct
24 Correct 65 ms 2140 KB Output is correct
25 Correct 64 ms 2656 KB Output is correct
26 Correct 66 ms 2204 KB Output is correct
27 Correct 64 ms 2040 KB Output is correct
28 Correct 93 ms 2168 KB Output is correct
29 Correct 66 ms 2212 KB Output is correct
30 Correct 31 ms 1272 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 256 KB Output is correct