Submission #744718

#TimeUsernameProblemLanguageResultExecution timeMemory
744718CutebolGap (APIO16_gap)C++17
0 / 100
60 ms1180 KiB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
const int inf = 1e18 ;

ll findGap(int T , int n){
    ll l = 1 , r = 1e18 , x , y, ans = inf , rr ;
    MinMax( l , r , &x , &y ) ;
    rr = y ;
    ll len = (y-x-1)/(n-1) ;
    l = x , r = y ;
    MinMax( x+1 , x+1+len+(n%len) , &l , &r ) ;
    if ( l != -1 ) ans = min ( ans , abs(x-l) ) ;
    x += len+(n%len)+1 ; y = r ;
    for ( ll i = 1 ; i < n-1 ; i ++ ){
        MinMax( x+1 , x+1+len , &l , &r ) ;
        x += len ;
        if ( l != -1 )
        continue ;
        ans = min ( ans , abs( y-l ) ) ;
        y = r ;
    }
    if ( y != -1 ) ans = min ( ans , abs(y-rr) ) ;
    return ans ;
}

Compilation message (stderr)

gap.cpp:5:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
    5 | const int inf = 1e18 ;
      |                 ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...