Submission #560906

#TimeUsernameProblemLanguageResultExecution timeMemory
560906duypd4206Gap (APIO16_gap)C++14
100 / 100
60 ms1876 KiB
#include "gap.h" #include<bits/stdc++.h> #define ll long long using namespace std; const int maxn = 1e5 + 2; ll findGap(int t, int n) { ll a[maxn]; if(t==1){ a[0] = -1; a[n+1] = 2e18 + 1; for(int i = 1, j = n; i <= j; i++,j--) { MinMax(a[i-1]+1,a[j+1]-1,&a[i],&a[j]); } ll res = 0; for(int i = 1; i < n ; i++) res = max(res,abs(a[i+1] - a[i])); return res; } ll mn,mx; MinMax(-1,1e18,&mn,&mx); if(n == 2) return mx - mn; n--; ll gap = (mx - mn) / n; ll Pre = -1; ll res = 0; ll t1 = mn, t2 = mx; for(ll be = t1; be < t2; be+= gap + 1) { MinMax(be, be + gap,&mn,&mx); if(mn == -1) continue; if(Pre != -1) res = max(res, mn - Pre); Pre = mx; } return res; } //int main() //{ // //}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...