Submission #898748

#TimeUsernameProblemLanguageResultExecution timeMemory
898748Sir_Ahmed_ImranRice Hub (IOI11_ricehub)C++17
25 / 100
10 ms3540 KiB
///~~~LOTA~~~/// #include "ricehub.h" #include <bits/stdc++.h> using namespace std; #define nl '\n' #define ff first #define ss second #define ll long long #define append push_back #define pii pair<int,int> #define all(x) (x).begin(),(x).end() #define MAXN 100000 ll a[MAXN]; ll b[MAXN]; bool check(ll n,ll l,ll r,vector<ll>& v,ll x){ if(l==r) return 1; int mid=(l+r)/2; ll o=a[mid]+b[mid]; o-=a[l]+(v[mid]-v[l])*l; o-=b[r]+(v[r]-v[mid])*(n-r-1); if(o>x) return 0; return 1; } int besthub(int n,int m,int X[],ll x){ ll o,p,q; vector<ll> v; for(int i=0;i<n;i++) v.append(X[i]); a[0]=b[n-1]=o=p=q=0; for(int i=1;i<n;i++) a[i]=a[i-1]+i*(v[i]-v[i-1]); for(int i=n-2;i>=0;i--) b[i]=b[i+1]+(n-1-i)*(v[i+1]-v[i]); while(q<=n){ if(check(n,p,q,v,x)){ o=max(o,q-p); q++; } else p++; } return o; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...