Submission #536394

# Submission time Handle Problem Language Result Execution time Memory
536394 2022-03-13T07:27:26 Z qwerasdfzxcl Gap (APIO16_gap) C++14
100 / 100
66 ms 1188 KB
#include "gap.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
ll ans;

ll findGap(int T, int N){
    if (T==1){
        ll L, R, ans = 0;
        MinMax(0, (ll)1e18, &L, &R);
        int cnt = 1;
        while(true){
            ll nL, nR;
            if (L+1<=R-1 && cnt < (N+1)/2) MinMax(L+1, R-1, &nL, &nR);
          	else nL = -1;
            if (nL==-1) {ans = max(ans, R - L); return ans;}
            ans = max(ans, max(nL - L, R - nR));
            L = nL, R = nR;
            cnt++;
        }
    }
    ll L, R;
    MinMax(0, (ll)1e18, &L, &R);

    ll len = R - L;
    ll Bsz = len / (N-1);
    ans = Bsz;

    ll prv = -1;
    for (ll i=L;i<=R;i+=Bsz+1){
        ll tL, tR;
        MinMax(i, i+Bsz, &tL, &tR);
        if (tL!=-1 && prv!=-1) ans = max(ans, tL - prv);
        if (tR!=-1) prv = tR;
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 12 ms 468 KB Output is correct
17 Correct 9 ms 464 KB Output is correct
18 Correct 10 ms 432 KB Output is correct
19 Correct 9 ms 524 KB Output is correct
20 Correct 9 ms 464 KB Output is correct
21 Correct 37 ms 1036 KB Output is correct
22 Correct 39 ms 1056 KB Output is correct
23 Correct 47 ms 1080 KB Output is correct
24 Correct 39 ms 1100 KB Output is correct
25 Correct 36 ms 996 KB Output is correct
26 Correct 40 ms 1076 KB Output is correct
27 Correct 39 ms 1056 KB Output is correct
28 Correct 35 ms 1060 KB Output is correct
29 Correct 43 ms 1060 KB Output is correct
30 Correct 32 ms 1068 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 2 ms 208 KB Output is correct
16 Correct 13 ms 516 KB Output is correct
17 Correct 13 ms 464 KB Output is correct
18 Correct 14 ms 472 KB Output is correct
19 Correct 13 ms 428 KB Output is correct
20 Correct 7 ms 516 KB Output is correct
21 Correct 66 ms 1096 KB Output is correct
22 Correct 55 ms 1188 KB Output is correct
23 Correct 50 ms 968 KB Output is correct
24 Correct 51 ms 1076 KB Output is correct
25 Correct 52 ms 1084 KB Output is correct
26 Correct 59 ms 1060 KB Output is correct
27 Correct 52 ms 1064 KB Output is correct
28 Correct 50 ms 1100 KB Output is correct
29 Correct 59 ms 1048 KB Output is correct
30 Correct 30 ms 1140 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct