Submission #614108

# Submission time Handle Problem Language Result Execution time Memory
614108 2022-07-30T18:55:13 Z nohaxjustsoflo Gap (APIO16_gap) C++17
100 / 100
60 ms 1868 KB
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> order_set;
mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
//uniform_int_distribution<int> gen; ///(min, max)
//int random() {return gen(mt_rand);}
const int mxN=1e5+5;
const int mod=998244353;
const int mxlogN=40;
const int mxK=26;
const ll inf=1e18;
const int K=600;

void MinMax(ll s, ll t, ll *mn, ll *mx);
ll a[mxN];
ll findGap(int t, int n)
{
    if(t==1)
    {
        ll mn=0,mx=inf;
        for(int l=0, r=n-1; l<=r; l++, r--)
        {
            MinMax(mn,mx,&a[l],&a[r]);
            mn=a[l]+1;
            mx=a[r]-1;
        }
        ll ans=0;
        for(int i=1; i<n; i++) ans=max(ans,a[i]-a[i-1]);
        return ans;
    }
    ll mn,mx;
    MinMax(0,inf,&mn,&mx);
    ll gap=(mx-mn+n-1-1)/(n-1);
    ll x=mn,y=mn;
    while(x<mx)
    {
        ll mn2, mx2;
        MinMax(x+1,min(inf,y+gap),&mn2,&mx2);
        y+=gap;
        if(~mn2)
        {
            gap=max(gap,mn2-x);
            x=mx2;
        }
    }
    return gap;
}
/*
int main()
{

}*/
/*
7 3
4 1 3 4 0 2 3
*/
# 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 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 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 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 19 ms 720 KB Output is correct
17 Correct 9 ms 720 KB Output is correct
18 Correct 9 ms 668 KB Output is correct
19 Correct 11 ms 720 KB Output is correct
20 Correct 8 ms 704 KB Output is correct
21 Correct 60 ms 1840 KB Output is correct
22 Correct 37 ms 1796 KB Output is correct
23 Correct 47 ms 1752 KB Output is correct
24 Correct 36 ms 1752 KB Output is correct
25 Correct 34 ms 1792 KB Output is correct
26 Correct 41 ms 1784 KB Output is correct
27 Correct 38 ms 1864 KB Output is correct
28 Correct 42 ms 1788 KB Output is correct
29 Correct 38 ms 1868 KB Output is correct
30 Correct 36 ms 1856 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 1 ms 208 KB Output is correct
4 Correct 1 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 7 ms 464 KB Output is correct
17 Correct 7 ms 524 KB Output is correct
18 Correct 6 ms 436 KB Output is correct
19 Correct 7 ms 464 KB Output is correct
20 Correct 6 ms 528 KB Output is correct
21 Correct 24 ms 968 KB Output is correct
22 Correct 24 ms 1072 KB Output is correct
23 Correct 24 ms 972 KB Output is correct
24 Correct 22 ms 1068 KB Output is correct
25 Correct 47 ms 1068 KB Output is correct
26 Correct 24 ms 1072 KB Output is correct
27 Correct 33 ms 1016 KB Output is correct
28 Correct 25 ms 1072 KB Output is correct
29 Correct 38 ms 1068 KB Output is correct
30 Correct 19 ms 1104 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct