Submission #752853

# Submission time Handle Problem Language Result Execution time Memory
752853 2023-06-04T04:48:22 Z winter0101 Gap (APIO16_gap) C++14
100 / 100
59 ms 1864 KB
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#include "gap.h"
using namespace std;
const int maxn=1e6;
using ll=long long int;
long long a[100009];
long long findGap(int t, int n){
    if (t==1){
        a[0]=-1;
        a[n+1]=2e18;
        for (int i=1,j=n;i<=j;i++,j--){
            MinMax(a[i-1]+1, a[j+1]-1, &a[i], &a[j]);
        }
        long long ans=-1;
        for (int i=2;i<=n;i++){
            ans=max(ans,a[i]-a[i-1]);
        }
        return ans;
    }
    else {
        MinMax(0,1e18,&a[1],&a[n]);
        long long temp=(a[n]-a[1])/(n-1);
        if (n==2)return a[n]-a[1];
        long long r=-1;
        long long ans=-1;
        for (long long ret=a[1];ret<a[n];ret+=temp+1){
            long long mn,mx;
            MinMax(ret,ret+temp,&mn,&mx);
            if (mn==-1)continue;
            if (r!=-1)ans=max(ans,mn-r);
            if (mx!=-1)r=mx;
        }
        return ans;
    }
}
# 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 1 ms 208 KB Output is correct
9 Correct 1 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 9 ms 684 KB Output is correct
17 Correct 9 ms 596 KB Output is correct
18 Correct 10 ms 688 KB Output is correct
19 Correct 9 ms 592 KB Output is correct
20 Correct 8 ms 592 KB Output is correct
21 Correct 42 ms 1820 KB Output is correct
22 Correct 35 ms 1760 KB Output is correct
23 Correct 42 ms 1832 KB Output is correct
24 Correct 36 ms 1864 KB Output is correct
25 Correct 31 ms 1864 KB Output is correct
26 Correct 36 ms 1860 KB Output is correct
27 Correct 35 ms 1812 KB Output is correct
28 Correct 35 ms 1856 KB Output is correct
29 Correct 34 ms 1824 KB Output is correct
30 Correct 30 ms 1804 KB Output is correct
31 Correct 0 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 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 432 KB Output is correct
17 Correct 13 ms 528 KB Output is correct
18 Correct 13 ms 432 KB Output is correct
19 Correct 12 ms 464 KB Output is correct
20 Correct 6 ms 464 KB Output is correct
21 Correct 48 ms 1068 KB Output is correct
22 Correct 50 ms 1092 KB Output is correct
23 Correct 59 ms 1048 KB Output is correct
24 Correct 51 ms 1068 KB Output is correct
25 Correct 44 ms 984 KB Output is correct
26 Correct 50 ms 1056 KB Output is correct
27 Correct 50 ms 1060 KB Output is correct
28 Correct 52 ms 1092 KB Output is correct
29 Correct 56 ms 980 KB Output is correct
30 Correct 29 ms 1088 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct