Submission #614108

#TimeUsernameProblemLanguageResultExecution timeMemory
614108nohaxjustsofloGap (APIO16_gap)C++17
100 / 100
60 ms1868 KiB
#include <bits/stdc++.h> #include <iostream> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> order_set; mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count()); //uniform_int_distribution<int> gen; ///(min, max) //int random() {return gen(mt_rand);} const int mxN=1e5+5; const int mod=998244353; const int mxlogN=40; const int mxK=26; const ll inf=1e18; const int K=600; void MinMax(ll s, ll t, ll *mn, ll *mx); ll a[mxN]; ll findGap(int t, int n) { if(t==1) { ll mn=0,mx=inf; for(int l=0, r=n-1; l<=r; l++, r--) { MinMax(mn,mx,&a[l],&a[r]); mn=a[l]+1; mx=a[r]-1; } ll ans=0; for(int i=1; i<n; i++) ans=max(ans,a[i]-a[i-1]); return ans; } ll mn,mx; MinMax(0,inf,&mn,&mx); ll gap=(mx-mn+n-1-1)/(n-1); ll x=mn,y=mn; while(x<mx) { ll mn2, mx2; MinMax(x+1,min(inf,y+gap),&mn2,&mx2); y+=gap; if(~mn2) { gap=max(gap,mn2-x); x=mx2; } } return gap; } /* int main() { }*/ /* 7 3 4 1 3 4 0 2 3 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...