Submission #467690

# Submission time Handle Problem Language Result Execution time Memory
467690 2021-08-24T03:19:20 Z SirCovidThe19th Gap (APIO16_gap) C++17
100 / 100
62 ms 1956 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std; 

#define ll long long

ll findGap(int t, int n){
    ll mn = 1, mx = 1e18, A[n], lim, lb, ans = 0; 
    if (t == 1){
        for (ll i = 0, j = n - 1; i <= j; i++, j--){
            MinMax(mn, mx, &mn, &mx);
            A[i] = mn; A[j] = mx;
            mn++; mx--;
        }
        for (ll i = 1; i < n; i++)
            ans = max(ans, A[i] - A[i - 1]);
    }
    else{
        MinMax(mn, mx, &mn, &mx); 
        lb = (mx - mn - 1) / (n - 1) + 1; lim = mx;
        for (ll l = mn + 1, r = l + lb - 1, prvMx = mn; l <= lim; l += lb, r += lb){
            MinMax(l, r, &mn, &mx);
            ans = max(ans, mn - prvMx);
            if (~mx) prvMx = mx; 
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 1 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 0 ms 200 KB Output is correct
9 Correct 0 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 12 ms 584 KB Output is correct
17 Correct 12 ms 592 KB Output is correct
18 Correct 11 ms 712 KB Output is correct
19 Correct 12 ms 616 KB Output is correct
20 Correct 9 ms 584 KB Output is correct
21 Correct 44 ms 1724 KB Output is correct
22 Correct 46 ms 1944 KB Output is correct
23 Correct 46 ms 1856 KB Output is correct
24 Correct 46 ms 1816 KB Output is correct
25 Correct 43 ms 1816 KB Output is correct
26 Correct 45 ms 1764 KB Output is correct
27 Correct 47 ms 1760 KB Output is correct
28 Correct 45 ms 1800 KB Output is correct
29 Correct 45 ms 1852 KB Output is correct
30 Correct 35 ms 1864 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 0 ms 200 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 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 1 ms 200 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 0 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 15 ms 584 KB Output is correct
17 Correct 15 ms 692 KB Output is correct
18 Correct 15 ms 704 KB Output is correct
19 Correct 15 ms 584 KB Output is correct
20 Correct 7 ms 700 KB Output is correct
21 Correct 62 ms 1956 KB Output is correct
22 Correct 62 ms 1820 KB Output is correct
23 Correct 60 ms 1728 KB Output is correct
24 Correct 62 ms 1820 KB Output is correct
25 Correct 55 ms 1856 KB Output is correct
26 Correct 62 ms 1892 KB Output is correct
27 Correct 62 ms 1828 KB Output is correct
28 Correct 62 ms 1856 KB Output is correct
29 Correct 61 ms 1856 KB Output is correct
30 Correct 35 ms 1828 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 0 ms 200 KB Output is correct