Submission #404213

#TimeUsernameProblemLanguageResultExecution timeMemory
404213myrcellaGap (APIO16_gap)C++17
100 / 100
1311 ms5448 KiB
#include "gap.h" #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pii pair<int,int> #define pll pair<long long,long long> #define pb push_back #define debug(x) cerr<<#x<<"="<<x<<endl #define pq priority_queue #define inf 0x3f #define rep(i,a,b) for (int i=a;i<(b);i++) #define MP make_pair #define SZ(x) (int(x.size())) #define ll long long #define mod 1000000007 #define ALL(x) x.begin(),x.end() void inc(int &a,int b) {a=(a+b)%mod;} void dec(int &a,int b) {a=(a-b+mod)%mod;} int lowbit(int x) {return x&(-x);} ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;} const ll MAX=1000000000000000000; const int maxn=1e5+10; ll a[maxn]; long long findGap(int T, int N) { if (T==1) { int cur=0; ll l=0,r=MAX; rep(i,0,(N+1)/2) { ll tmp1,tmp2; MinMax(l,r,&tmp1,&tmp2); a[cur++]=tmp1,a[N-cur]=tmp2; l=tmp1+1,r=tmp2-1; } ll ans=0; rep(i,1,N) ans=max(ans,a[i]-a[i-1]); return ans; } ll L,R; MinMax(0ll,MAX,&L,&R); debug(L),debug(R); ll mn=(R-L+N-2)/(N-1); ll ans=mn; ll lst=L; for (ll i=L+1;i<R;i+=mn) { ll tmp1,tmp2; MinMax(i,min(i+mn-1,R),&tmp1,&tmp2); debug(tmp1);debug(lst); if (tmp1!=-1) { ans=max(ans,tmp1-lst); lst=tmp2; } } return max(R-lst,ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...