Submission #489210

#TimeUsernameProblemLanguageResultExecution timeMemory
489210leakedGap (APIO16_gap)C++14
30 / 100
62 ms9004 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define f first #define s second pair<ll,ll> ask(ll l,ll r){ ll *a,*b; a=new long long(),b=new long long(); MinMax(l,r,a,b); return {*a,*b}; } long long findGap(int T, int N) { if(T==1){ long long x=0,y=1e18; vector<long long>vc; while(N>=1){ long long *a,*b; a=new long long(),b=new long long(); MinMax(x,y,a,b); x=*a,y=*b; vc.push_back(x); vc.push_back(y); x++;y--; N-=2; } sort(vc.begin(),vc.end()); long long ans=0; for(int i=1;i<(int)vc.size();i++) ans=max(ans,vc[i]-vc[i-1]); return ans; } else{ long long x=0; ll y=1e18; auto c=ask(x,y); x=c.f,y=c.s; ll d=ceil((ld)(y-x)/(N-1))+1; ll ans=d; while(x+d<y){ ll cnt=1; while(1){ c=ask(x+1,x+cnt*d); if(c.f!=-1) break; else cnt++; } ans=max(ans,c.f-x); x=c.s; } return ans; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...