Submission #22017

#TimeUsernameProblemLanguageResultExecution timeMemory
22017HiasatGap (APIO16_gap)C++14
100 / 100
63 ms6772 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; vector<ll> v; long long findGap(int T, int N) { ll mx = 0; if(T == 2){ ll lo,hi; MinMax(1, 1e18, &lo, &hi); ll big = hi; ll sure = (hi-lo)/(N-1) + ((hi-lo)%(N-1) != 0); ll cur = lo; ll ed = lo + sure; ll prev = -1; ll step = sure; while(cur + step< big){ MinMax(cur, ed, &lo, &hi); if(hi == -1 || hi == cur){ ed = ed + step; continue; } step = max(step,hi - lo); if(prev != -1){ step = max(step,lo - prev); } prev = hi; cur = hi+1; ed = cur + step; } return step; }else{ ll lo = 1, hi = 1e18; int rem =(N+1)/2; while(rem--){ ll a , b; MinMax(lo,hi,&a,&b); if(a == -1) break; v.push_back(a); v.push_back(b); lo = a+1; hi = b-1; } } sort(v.begin(),v.end()); for (int i = 0; i+1 < v.size(); ++i){ mx = max(mx,v[i+1]-v[i]); } return mx; }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:52:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i+1 < v.size(); ++i){
                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...