Submission #182424

# Submission time Handle Problem Language Result Execution time Memory
182424 2020-01-09T19:00:30 Z AQT Gap (APIO16_gap) C++14
100 / 100
71 ms 2044 KB
#include <bits/stdc++.h>
#include "gap.h"

using namespace std;

long long arr[100005];

long long findGap(int T, int N){
    if(T == 1){
        int l = 1, r = N;
        long long lstl = -1, lstr = 1000000000000000001LL;
        while(l <= r){
            MinMax(lstl+1, lstr-1, &lstl, &lstr);
            arr[l++] = lstl, arr[r--] = lstr;
        }
        long long ans = 0;
        for(int i = 2; i<=N; i++){
            ans = max(ans, arr[i]-arr[i-1]);
        }
        return ans;
    }
    fill(arr+1, arr+1+N, -1);
    long long s, e;
    MinMax(0, 1000000000000000000LL, &s, &e);
    long long d = (e-s-2+N)/(N-1);
    arr[1] = s, arr[N] = e;
    long long lst = s;
    long long n = s;
    long long ans = 0;
    while(n < e){
        long long t;
        MinMax(n+1, min(e-1, n+d), &s, &t);
        ans = max(ans, s-lst);
        if(t+1){
            lst = t;
        }
        n += d;
    }
    ans = max(ans, e-lst);
    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 1 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 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 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 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 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 15 ms 760 KB Output is correct
17 Correct 15 ms 760 KB Output is correct
18 Correct 15 ms 760 KB Output is correct
19 Correct 15 ms 764 KB Output is correct
20 Correct 11 ms 760 KB Output is correct
21 Correct 54 ms 1912 KB Output is correct
22 Correct 54 ms 1912 KB Output is correct
23 Correct 54 ms 1860 KB Output is correct
24 Correct 54 ms 1912 KB Output is correct
25 Correct 46 ms 2040 KB Output is correct
26 Correct 54 ms 1912 KB Output is correct
27 Correct 54 ms 1912 KB Output is correct
28 Correct 54 ms 1916 KB Output is correct
29 Correct 54 ms 1912 KB Output is correct
30 Correct 40 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 0 ms 376 KB Output is correct
5 Correct 2 ms 376 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 376 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 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 18 ms 760 KB Output is correct
17 Correct 19 ms 760 KB Output is correct
18 Correct 19 ms 760 KB Output is correct
19 Correct 18 ms 760 KB Output is correct
20 Correct 10 ms 760 KB Output is correct
21 Correct 71 ms 2044 KB Output is correct
22 Correct 69 ms 1900 KB Output is correct
23 Correct 69 ms 1948 KB Output is correct
24 Correct 70 ms 2040 KB Output is correct
25 Correct 66 ms 1912 KB Output is correct
26 Correct 70 ms 1912 KB Output is correct
27 Correct 69 ms 1912 KB Output is correct
28 Correct 70 ms 1916 KB Output is correct
29 Correct 70 ms 1916 KB Output is correct
30 Correct 38 ms 1912 KB Output is correct
31 Correct 2 ms 380 KB Output is correct
32 Correct 2 ms 376 KB Output is correct