Submission #227635

# Submission time Handle Problem Language Result Execution time Memory
227635 2020-04-28T08:01:48 Z Arg_007 Gap (APIO16_gap) C++14
100 / 100
84 ms 2464 KB
#include <bits/stdc++.h>

#include "gap.h"


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("hard1.txt","r",stdin)
#define OUT freopen("hard1.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 1000005

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

#define INF 1000000000000000000LL
#define alpha 26
#define mod 998244353LL
#define maxn 500005
#define LOG 18

/*
void MinMax(i64 s, i64 t, i64 &mn, i64 &mx)
{

}
*/
vector <i64> solve1(int n,i64 lo, i64 hi)
{
    vector <i64> v ;
    v.pb(lo) ; v.pb(hi) ;
    for(int i=1 ; i<(n+1)/2 ; i++ )
    {
        lo++ ; hi-- ;
        i64 mn , mx ;
        MinMax(lo,hi,&mn,&mx) ;
        v.pb(mn) ; v.pb(mx) ;
        lo = mn ; hi = mx ;
    }
    sort( v.begin() , v.end() ) ;
    return v ;
}

vector <i64> solve2( int n , i64 lo, i64 hi )
{
    vector <i64> v ;
    v.pb(lo) ;
    //v.pb(hi) ;
    i64 d = ( hi-lo + n-1 -1 )/(n-1) ;

    i64 cur = lo ;
    while( cur < hi )
    {
        cur++ ;
        i64 mn , mx ;
        MinMax(cur,cur+d, &mn,&mx) ;
        if( mn!=-1 )
        {
            v.pb(mn) ;
            if( mn!=mx ) v.pb(mx) ;
        }
        cur += d ;
    }
    sort(v.begin() , v.end() ) ;
    return v ;
}

i64 findGap( int t , int n )
{

    i64 mn , mx ;
    MinMax(0,INF,&mn,&mx) ;

    vector <i64> p ;

    if(t==1) p = solve1(n,mn,mx) ;
    else p = solve2(n,mn,mx) ;
    i64 ans = 0 ;
    for(int i=1 ; i<(int)p.size() ; i++) ans = max( ans , p[i]-p[i-1] ) ;
    return ans ;
}

/*
int main()
{


    return 0 ;
}
*/
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 18 ms 896 KB Output is correct
17 Correct 18 ms 896 KB Output is correct
18 Correct 18 ms 896 KB Output is correct
19 Correct 19 ms 896 KB Output is correct
20 Correct 16 ms 1024 KB Output is correct
21 Correct 60 ms 2288 KB Output is correct
22 Correct 60 ms 2288 KB Output is correct
23 Correct 59 ms 2288 KB Output is correct
24 Correct 60 ms 2276 KB Output is correct
25 Correct 52 ms 2248 KB Output is correct
26 Correct 63 ms 2456 KB Output is correct
27 Correct 68 ms 2288 KB Output is correct
28 Correct 61 ms 2288 KB Output is correct
29 Correct 60 ms 2292 KB Output is correct
30 Correct 55 ms 2464 KB Output is correct
31 Correct 4 ms 384 KB Output is correct
32 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 21 ms 896 KB Output is correct
17 Correct 21 ms 896 KB Output is correct
18 Correct 21 ms 1024 KB Output is correct
19 Correct 21 ms 896 KB Output is correct
20 Correct 12 ms 512 KB Output is correct
21 Correct 84 ms 2248 KB Output is correct
22 Correct 75 ms 2288 KB Output is correct
23 Correct 73 ms 2392 KB Output is correct
24 Correct 75 ms 2288 KB Output is correct
25 Correct 75 ms 2288 KB Output is correct
26 Correct 82 ms 2288 KB Output is correct
27 Correct 83 ms 2288 KB Output is correct
28 Correct 81 ms 2448 KB Output is correct
29 Correct 77 ms 2320 KB Output is correct
30 Correct 39 ms 1516 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 4 ms 384 KB Output is correct