제출 #835892

#제출 시각아이디문제언어결과실행 시간메모리
835892BT21tataGap (APIO16_gap)C++17
43.91 / 100
58 ms1108 KiB
#include "gap.h" #include<bits/stdc++.h> typedef long long ll; using namespace std; long long findGap(int T, int n) { ll mn, mx; MinMax(0, 1e18, &mn, &mx); ll gap=(mx-mn-1)/(n-1)+1; ll l=mn, r=mx, curl=l, curr=l+gap-1, ans=gap; //cout<<curr<<endl; while(curr-gap<=r) { //cout<<curl<<' '<<curr<<" "<<ans<<endl; MinMax(curl+1, curr, &mn, &mx); if(mx==-1) mn=mx=curl; else mn=curl; if(mn!=mx and mx-mn<=gap) curl=mx, curr=curl+gap-1; else if(mn==mx) curl=mn, curr+=gap; else { MinMax(curr-gap+1, curr, &mn, &mx); if(mn==mx) ans=max(ans, mx-curl); else ans=max(ans, mn-curl); curl=mx, curr=curl+gap-1; } } return ans; } /* 11 5 7 8 100 130 190 200 201 203 1000 2004 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...