Submission #860876

#TimeUsernameProblemLanguageResultExecution timeMemory
860876Huseyn123Rice Hub (IOI11_ricehub)C++17
100 / 100
20 ms5724 KiB
#include "ricehub.h" #include <bits/stdc++.h> #define MAX 200001 #define INF LLONG_MAX #define MOD 1000000007 #define mp make_pair #define mt make_tuple #define pb push_back #define ins insert #define ff first #define ss second #define gett(x,m) get<m>(x) #define all(a) a.begin(),a.end() #define lb(a,b) lower_bound(all(a),b) #define ub(a,b) upper_bound(all(a),b) #define sortv(a) sort(all(a)) #define sorta(a,sz) sort(a,a+sz) #define inputar(a,b){\ for(int i=0;i<b;i++){\ cin >> a[i];\ }\ } #define inputvec(a,b){\ for(int i=0;i<b;i++){\ ll num;\ cin >> num;\ a.pb(num);\ }\ } #define outputar(a,b){\ for(int i=0;i<b;i++){\ cout << a[i] << " ";\ }\ cout << "\n";\ } #define outputvec(a){\ for(auto x:a){\ cout << x << " ";\ }\ cout << "\n";\ } #define reset(a,n,v){\ for(int i=0;i<n;i++){\ a[i]=v;\ }\ } using namespace std; typedef long long ll; typedef unsigned long long ull; typedef tuple<ll,ll,ll> tll; typedef pair<ll,ll> pll; typedef pair<int,int> pii; typedef double db; typedef long double ldb; inline void USACO(string filename){ freopen((filename+".in").c_str(),"r",stdin); freopen((filename+".out").c_str(),"w",stdout); } ll Y[MAX],Y1[MAX],n; ll b; ll f(ll h,ll x,ll y){ ll res=0; ll h1=Y[h]; if(x>0){ h1-=Y[x-1]; } ll h2=Y[y]-Y[h]; res+=(h-x+1)*Y1[h]+h2-(y-h)*Y1[h]-h1; return res; } bool f1(ll h,ll h3){ if(h3%2==0){ if(h-h3/2+1>=0 && h+h3/2<n && f(h,h-h3/2+1,h+h3/2)<=b){ //cout << h << " " << h3 << " " << 1 << "\n"; return true; } if(h-h3/2>=0 && h+h3/2-1<n && f(h,h-h3/2,h+h3/2-1)<=b){ //cout << h << " " << h3 << " " << 2 << "\n"; return true; } } else{ if(h-h3/2>=0 && h+h3/2<n && f(h,h-h3/2,h+h3/2)<=b){ //cout << h << " " << h3 << " " << 3 << "\n"; return true; } } return false; } int besthub(int R, int L, int X[], long long B) { b=B; n=R; for(int i=0;i<R;i++){ Y[i]=X[i]; Y1[i]=X[i]; } for(int i=1;i<R;i++){ Y[i]+=Y[i-1]; } int res=0; for(int i=0;i<R;i++){ int l,r; l=0,r=R; while(l<r){ ll mid=(l+r+1)/2; if(f1(i,mid)){ l=mid; } else{ r=mid-1; } } res=max(res,l); //cout << i << " " << l << "\n"; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...