Submission #712719

#TimeUsernameProblemLanguageResultExecution timeMemory
712719dungnguyenn_05Gap (APIO16_gap)C++17
0 / 100
66 ms1188 KiB
#include<bits/stdc++.h> #include "gap.h" #define fs first #define sc second #define pb push_back #define all(x) x.begin(),x.end() using namespace std; typedef long long ll; typedef pair<ll,ll> pi; ll dis,L,R=1e18; pi pos(int u) { return {L+dis*(u-1),min(R,L+(dis*u)-1)}; } long long findGap(int T, int N) { ll s=0,t=1e18,mn,mx; MinMax(s,t,&L,&R); dis=(R-L+1)/(N-1); ll st=-1,cnt=0,res=0; while(st==-1) { cnt++; pi val=pos(cnt); MinMax(val.fs,val.sc,&mn,&st); } for(int i=cnt+1;;i++) { pi val=pos(i); MinMax(val.fs,val.sc,&mn,&mx); if(mn==-1) continue; res=max(res,mn-st); st=mx; if(mx==R) break; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...