Submission #708612

# Submission time Handle Problem Language Result Execution time Memory
708612 2023-03-12T04:31:28 Z yuuhi Gap (APIO16_gap) C++14
100 / 100
49 ms 1864 KB
#include<bits/stdc++.h>
#include "gap.h"

#define f first
#define s second
#define double long double
#define _size(x) ((int)((x).size()))

using namespace std ;

typedef pair< long long , long long > ii ;

const int maxN = 1e5 + 10 ;

long long a[maxN] ;

long long findGap (int T , int n) {
    if (T == 1) {
        long long l = 0 , r = 1e18 ;
        for (int i = 1 ; i <= (n + 1) / 2 ; ++ i) {
            MinMax(l , r , &a[i] , &a[n - i + 1]) ;
            l = a[i] + 1 ; r = a[n - i + 1] - 1 ;
        }
        long long ans = 0 ;
        for (int i = 1 ; i < n ; ++ i) ans = max(ans , a[i + 1] - a[i]) ;
        return ans ;
    }
    else {
        MinMax(0 , 1e18 , &a[1] , &a[n]) ;
        long long lent = (a[n] - a[1] - 1) / (n - 1) + 1 ;
        for (long long l = a[1] , r = a[1] + lent ; l < a[n] ;) {
            if (r <= l) r = l + lent ;
            long long lo , hi ;
            MinMax(l + 1 , r , &lo , &hi) ;
            if (lo == -1) {
                r += lent ;
            }
            else {
                lent = max(lent , lo - l) ;
                l = hi ;
                r = l + lent ;
            }
        }
        return lent ;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 208 KB Output is correct
6 Correct 1 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 1 ms 336 KB Output is correct
11 Correct 2 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 11 ms 672 KB Output is correct
17 Correct 10 ms 684 KB Output is correct
18 Correct 13 ms 700 KB Output is correct
19 Correct 12 ms 624 KB Output is correct
20 Correct 8 ms 720 KB Output is correct
21 Correct 44 ms 1832 KB Output is correct
22 Correct 39 ms 1848 KB Output is correct
23 Correct 37 ms 1736 KB Output is correct
24 Correct 38 ms 1828 KB Output is correct
25 Correct 33 ms 1736 KB Output is correct
26 Correct 39 ms 1832 KB Output is correct
27 Correct 37 ms 1864 KB Output is correct
28 Correct 49 ms 1832 KB Output is correct
29 Correct 37 ms 1832 KB Output is correct
30 Correct 31 ms 1836 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 1 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 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 7 ms 456 KB Output is correct
17 Correct 8 ms 496 KB Output is correct
18 Correct 7 ms 512 KB Output is correct
19 Correct 6 ms 464 KB Output is correct
20 Correct 5 ms 464 KB Output is correct
21 Correct 26 ms 1168 KB Output is correct
22 Correct 25 ms 1088 KB Output is correct
23 Correct 24 ms 1000 KB Output is correct
24 Correct 26 ms 972 KB Output is correct
25 Correct 46 ms 1024 KB Output is correct
26 Correct 26 ms 1152 KB Output is correct
27 Correct 30 ms 1052 KB Output is correct
28 Correct 26 ms 1084 KB Output is correct
29 Correct 25 ms 968 KB Output is correct
30 Correct 23 ms 1012 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct