Submission #561209

# Submission time Handle Problem Language Result Execution time Memory
561209 2022-05-12T13:09:21 Z fdnfksd Gap (APIO16_gap) C++14
100 / 100
58 ms 1864 KB
#include<bits/stdc++.h>
#include "gap.h"
using namespace std;
using ll = long long;
ll a[100009];
ll findGap(int t, int n)
{
    ll res=0;
    if(t==1)
    {
        a[0]=-1;
        a[n+1]=2e18+10;
        ll i=1,j=n;
        while(i<=j)
        {
            MinMax(a[i-1]+1,a[j+1]-1,&a[i],&a[j]);
            i++;
            j--;
        }

        for(int i=2;i<=n;i++) res=max(res,a[i]-a[i-1]);
        return res;
    }
    MinMax(-1,2e18,&a[1],&a[n]);
    if(n==2) return a[n]-a[1];
    ll dis=(a[n]-a[1])/(n-1);
    ll prev=-1, now=-1;
    for(ll i=a[1];i<a[n];i+=dis+1)
    {
        ll tmp=-1;
        MinMax(i,i+dis,&tmp,&now);
        if(tmp==-1) continue;
        if(prev!=-1)
        {
            res=max(res,tmp-prev);
        }
        prev=now;
    }
    return res;
}/*
int main()
{
    findGap();
}*/
# 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 336 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 10 ms 688 KB Output is correct
17 Correct 11 ms 716 KB Output is correct
18 Correct 11 ms 636 KB Output is correct
19 Correct 11 ms 680 KB Output is correct
20 Correct 8 ms 592 KB Output is correct
21 Correct 44 ms 1800 KB Output is correct
22 Correct 38 ms 1832 KB Output is correct
23 Correct 38 ms 1736 KB Output is correct
24 Correct 38 ms 1860 KB Output is correct
25 Correct 34 ms 1764 KB Output is correct
26 Correct 38 ms 1864 KB Output is correct
27 Correct 38 ms 1820 KB Output is correct
28 Correct 38 ms 1744 KB Output is correct
29 Correct 45 ms 1800 KB Output is correct
30 Correct 32 ms 1864 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 336 KB Output is correct
8 Correct 1 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 352 KB Output is correct
13 Correct 2 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 14 ms 464 KB Output is correct
17 Correct 13 ms 464 KB Output is correct
18 Correct 13 ms 464 KB Output is correct
19 Correct 13 ms 480 KB Output is correct
20 Correct 6 ms 464 KB Output is correct
21 Correct 52 ms 1060 KB Output is correct
22 Correct 52 ms 1064 KB Output is correct
23 Correct 53 ms 976 KB Output is correct
24 Correct 53 ms 976 KB Output is correct
25 Correct 48 ms 1064 KB Output is correct
26 Correct 58 ms 1080 KB Output is correct
27 Correct 52 ms 1088 KB Output is correct
28 Correct 53 ms 976 KB Output is correct
29 Correct 51 ms 1084 KB Output is correct
30 Correct 28 ms 1068 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct