Submission #197493

#TimeUsernameProblemLanguageResultExecution timeMemory
197493handlenameGap (APIO16_gap)C++17
100 / 100
73 ms3084 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; long long ans,mini,maxi; long long findGap(int t, int n){ maxi=1e18; MinMax(0,1e18,&mini,&maxi); if (t==1){ for (int i=1;i<(n+1)/2;i++){ long long cur1,cur2; MinMax(mini+1,maxi-1,&cur1,&cur2); ans=max(ans,cur1-mini); ans=max(ans,maxi-cur2); mini=cur1; maxi=cur2; } ans=max(ans,maxi-mini); } else { if (n==2) return maxi-mini; long long size=maxi-mini+1; long long l=mini+1,lastguy=mini; for (int i=1;i<n;i++){ long long cur1,cur2; long long curr=l+size/(n-1)-1; if (i<(size)%(n-1)) curr++; MinMax(l,curr,&cur1,&cur2); if (cur1!=-1){ ans=max(ans,cur1-lastguy); lastguy=cur2; } l=curr+1; } ans=max(ans,l-lastguy); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...