Submission #860859

#TimeUsernameProblemLanguageResultExecution timeMemory
860859Huseyn123Rice Hub (IOI11_ricehub)C++17
68 / 100
1043 ms3676 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); } int Y[MAX],Y1[MAX]; ll f(int h,int x,int 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; } int besthub(int R, int L, int X[], long long B) { 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++){ for(int j=i;j<R;j++){ if((j-i+1)%2){ if(f(i+(j-i+1)/2,i,j)<=B){ res=max(res,j-i+1); } } else{ if(f(i+(j-i+1)/2,i,j)<=B){ res=max(res,j-i+1); } if(f(i+(j-i+1)/2-1,i,j)<=B){ res=max(res,j-i+1); } } } } 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...