Submission #565503

# Submission time Handle Problem Language Result Execution time Memory
565503 2022-05-21T02:23:29 Z Spade1 Gap (APIO16_gap) C++14
100 / 100
58 ms 1864 KB
#include<bits/stdc++.h>
#include "gap.h"
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define st first
#define nd second
#define pb push_back
#define INF INT_MAX
using namespace std;

const int NN = 1e5 + 10;


ll a[NN];
int cnt = 0;

ll findGap(int T, int N) {
    if (T == 1) {
        ll mn, mx;
        ll l = 0, r = 1e18;
        for (ll i = 0; i < (N+1)/2; ++i) {
            MinMax(l, r, &mn, &mx);
            a[cnt++] = mn;
            a[cnt++] = mx;
            l = mn+1, r = mx - 1;
        }
        sort(a, a+N);
        ll ans = 0;
        for (int i = 1; i <= N; ++i) ans = max(ans, a[i] - a[i-1]);
        return ans;
    }
    else {
        ll mn, mx;
        MinMax(0, 1e18, &mn, &mx);
        ll step = (mx - mn + N - 2)/(N - 1);
        ll ans = step;
        ll x, y, i = mn, l = mn;
        for (; i + step < mx; i += step+1) {
            MinMax(i, i+step, &x, &y);
            if (x != -1) {
                ans = max(ans, x-l);
                l = y;
            }
        }
        MinMax(i, mx, &x, &y);
        if (x != -1) ans = max(ans, x-l);
        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 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 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 0 ms 208 KB Output is correct
11 Correct 1 ms 336 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 13 ms 648 KB Output is correct
17 Correct 13 ms 720 KB Output is correct
18 Correct 10 ms 668 KB Output is correct
19 Correct 13 ms 624 KB Output is correct
20 Correct 8 ms 720 KB Output is correct
21 Correct 40 ms 1752 KB Output is correct
22 Correct 43 ms 1860 KB Output is correct
23 Correct 47 ms 1804 KB Output is correct
24 Correct 47 ms 1864 KB Output is correct
25 Correct 36 ms 1844 KB Output is correct
26 Correct 43 ms 1772 KB Output is correct
27 Correct 42 ms 1844 KB Output is correct
28 Correct 48 ms 1772 KB Output is correct
29 Correct 40 ms 1816 KB Output is correct
30 Correct 36 ms 1776 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 0 ms 208 KB Output is correct
8 Correct 1 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 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 13 ms 428 KB Output is correct
17 Correct 13 ms 516 KB Output is correct
18 Correct 13 ms 408 KB Output is correct
19 Correct 13 ms 516 KB Output is correct
20 Correct 6 ms 464 KB Output is correct
21 Correct 58 ms 1032 KB Output is correct
22 Correct 56 ms 1092 KB Output is correct
23 Correct 58 ms 968 KB Output is correct
24 Correct 51 ms 1052 KB Output is correct
25 Correct 52 ms 1028 KB Output is correct
26 Correct 58 ms 1060 KB Output is correct
27 Correct 52 ms 1056 KB Output is correct
28 Correct 55 ms 968 KB Output is correct
29 Correct 56 ms 1192 KB Output is correct
30 Correct 38 ms 1068 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct