Submission #448942

# Submission time Handle Problem Language Result Execution time Memory
448942 2021-08-02T02:22:21 Z JovanB Gap (APIO16_gap) C++17
100 / 100
68 ms 1856 KB
#include "gap.h"
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const ll INF = 1000000000000000000LL;
 
ll a[100005];
 
long long findGap(int T, int N){
 
    if(T == 1){
        int l = 1, r = N;
        a[N+1] = INF+1;
        while(l <= r){
            MinMax(a[l-1]+1, a[r+1]-1, &a[l], &a[r]);
            l++;
            r--;
        }
        ll res = 0;
        for(int i=2; i<=N; i++) res = max(res, a[i]-a[i-1]);
        return res;
    }
    ll mn, mx;
    MinMax(1, INF, &mn, &mx);
    ll block = (mx-mn+N-2)/(N-1);
    ll res = block;
    ll posl = mn;
    ll i;
    for(i=mn; i+block+1 <= mx; i += block+1){
        ll a, b;
        MinMax(i, i+block+1, &a, &b);
        if(a == -1) continue;
        res = max(res, a-posl);
        posl = b;
    }
    ll a, b;
    MinMax(i, mx, &a, &b);
    if(a != -1) res = max(res, a-posl);
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 0 ms 200 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 11 ms 648 KB Output is correct
17 Correct 13 ms 584 KB Output is correct
18 Correct 11 ms 676 KB Output is correct
19 Correct 11 ms 584 KB Output is correct
20 Correct 9 ms 584 KB Output is correct
21 Correct 44 ms 1856 KB Output is correct
22 Correct 48 ms 1844 KB Output is correct
23 Correct 44 ms 1856 KB Output is correct
24 Correct 45 ms 1820 KB Output is correct
25 Correct 38 ms 1780 KB Output is correct
26 Correct 50 ms 1812 KB Output is correct
27 Correct 44 ms 1856 KB Output is correct
28 Correct 45 ms 1824 KB Output is correct
29 Correct 43 ms 1740 KB Output is correct
30 Correct 36 ms 1848 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 0 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 292 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 0 ms 200 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 200 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 14 ms 516 KB Output is correct
17 Correct 15 ms 420 KB Output is correct
18 Correct 14 ms 456 KB Output is correct
19 Correct 15 ms 456 KB Output is correct
20 Correct 8 ms 456 KB Output is correct
21 Correct 64 ms 1056 KB Output is correct
22 Correct 60 ms 960 KB Output is correct
23 Correct 60 ms 960 KB Output is correct
24 Correct 60 ms 1080 KB Output is correct
25 Correct 55 ms 968 KB Output is correct
26 Correct 63 ms 960 KB Output is correct
27 Correct 62 ms 1048 KB Output is correct
28 Correct 68 ms 964 KB Output is correct
29 Correct 63 ms 1160 KB Output is correct
30 Correct 34 ms 1072 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 0 ms 200 KB Output is correct