Submission #560906

# Submission time Handle Problem Language Result Execution time Memory
560906 2022-05-12T04:46:01 Z duypd4206 Gap (APIO16_gap) C++14
100 / 100
60 ms 1876 KB
#include "gap.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1e5 + 2;

ll findGap(int t, int n)
{
    ll a[maxn];
    if(t==1){
        a[0] = -1;
        a[n+1] = 2e18 + 1;
        for(int i = 1, j = n; i <= j; i++,j--)
        {
            MinMax(a[i-1]+1,a[j+1]-1,&a[i],&a[j]);
        }
        ll res = 0;
        for(int i = 1; i < n ; i++)
            res = max(res,abs(a[i+1] - a[i]));
        return res;
    }
    ll mn,mx;
    MinMax(-1,1e18,&mn,&mx);
    if(n == 2) return mx - mn;
    n--;
    ll gap = (mx - mn) / n;
    ll Pre = -1;
    ll res = 0;
    ll t1 = mn, t2 = mx;
    for(ll be = t1; be < t2; be+= gap + 1)
    {
        MinMax(be, be + gap,&mn,&mx);
        if(mn == -1)
            continue;
        if(Pre != -1)
            res = max(res, mn - Pre);
        Pre = mx;
    }
    return res;
}

//int main()
//{
//
//}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 976 KB Output is correct
2 Correct 1 ms 1104 KB Output is correct
3 Correct 1 ms 976 KB Output is correct
4 Correct 1 ms 976 KB Output is correct
5 Correct 1 ms 976 KB Output is correct
6 Correct 1 ms 1104 KB Output is correct
7 Correct 1 ms 976 KB Output is correct
8 Correct 1 ms 1104 KB Output is correct
9 Correct 1 ms 976 KB Output is correct
10 Correct 1 ms 1104 KB Output is correct
11 Correct 1 ms 1104 KB Output is correct
12 Correct 1 ms 1104 KB Output is correct
13 Correct 2 ms 1104 KB Output is correct
14 Correct 1 ms 1104 KB Output is correct
15 Correct 1 ms 1104 KB Output is correct
16 Correct 10 ms 1300 KB Output is correct
17 Correct 9 ms 1276 KB Output is correct
18 Correct 10 ms 1312 KB Output is correct
19 Correct 12 ms 1304 KB Output is correct
20 Correct 8 ms 1296 KB Output is correct
21 Correct 37 ms 1780 KB Output is correct
22 Correct 36 ms 1840 KB Output is correct
23 Correct 36 ms 1860 KB Output is correct
24 Correct 48 ms 1740 KB Output is correct
25 Correct 33 ms 1832 KB Output is correct
26 Correct 37 ms 1788 KB Output is correct
27 Correct 37 ms 1816 KB Output is correct
28 Correct 37 ms 1832 KB Output is correct
29 Correct 36 ms 1824 KB Output is correct
30 Correct 30 ms 1872 KB Output is correct
31 Correct 1 ms 976 KB Output is correct
32 Correct 1 ms 1104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 976 KB Output is correct
2 Correct 1 ms 1104 KB Output is correct
3 Correct 1 ms 1104 KB Output is correct
4 Correct 1 ms 1104 KB Output is correct
5 Correct 1 ms 976 KB Output is correct
6 Correct 1 ms 1104 KB Output is correct
7 Correct 1 ms 1104 KB Output is correct
8 Correct 1 ms 976 KB Output is correct
9 Correct 1 ms 1104 KB Output is correct
10 Correct 1 ms 1104 KB Output is correct
11 Correct 1 ms 1104 KB Output is correct
12 Correct 1 ms 1104 KB Output is correct
13 Correct 1 ms 1104 KB Output is correct
14 Correct 1 ms 1104 KB Output is correct
15 Correct 1 ms 1104 KB Output is correct
16 Correct 14 ms 1232 KB Output is correct
17 Correct 12 ms 1232 KB Output is correct
18 Correct 14 ms 1292 KB Output is correct
19 Correct 13 ms 1296 KB Output is correct
20 Correct 7 ms 1232 KB Output is correct
21 Correct 54 ms 1852 KB Output is correct
22 Correct 60 ms 1828 KB Output is correct
23 Correct 59 ms 1864 KB Output is correct
24 Correct 50 ms 1876 KB Output is correct
25 Correct 60 ms 1856 KB Output is correct
26 Correct 53 ms 1796 KB Output is correct
27 Correct 51 ms 1860 KB Output is correct
28 Correct 53 ms 1872 KB Output is correct
29 Correct 54 ms 1816 KB Output is correct
30 Correct 30 ms 1832 KB Output is correct
31 Correct 1 ms 1104 KB Output is correct
32 Correct 1 ms 976 KB Output is correct