Submission #396221

#TimeUsernameProblemLanguageResultExecution timeMemory
396221giorgikobGap (APIO16_gap)C++14
30 / 100
68 ms1200 KiB
#include<bits/stdc++.h> #define ll long long #define ff first #define ss second #define pb push_back using namespace std; //#include "game.h" #include "gap.h" ll answer = 0; long long findGap(int T, int N) { ll l = -1, r = 1e18; r++; ll cnt = 0; int calls = 0; ll len = -1; if(T == 1){ while(true){ ll new_l,new_r; if(len != -1){ if((r-l) < len/N) break; } cnt++; if(answer >= r-l) break; if(cnt > (N+1)/2){ if(l != r){ answer = max(answer,r-l); } break; } if(l+1 > r-1){ if(l == r) break; answer = max(answer,r-l); break; } MinMax(l+1,r-1,&new_l,&new_r); calls++; if(new_l == -1){ answer = max(answer,r-l); break; } else { if(cnt > 1)answer = max(answer, max(new_l-l,r-new_r)); else len = new_r-new_l; l = new_l; r = new_r; } } } else { ll last = -1; MinMax(0,1e18,&l,&r); ll k = (r-l)/N+1; for(ll i = l; i+k-1 <= r; i += k){ ll a,b; MinMax(i,min(i+k-1,r),&a,&b); if(a == -1){ continue; } if(last != -1){ answer = max(answer,a-last); } last = b; } } return answer; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...