Submission #784131

#TimeUsernameProblemLanguageResultExecution timeMemory
784131gagik_2007Rice Hub (IOI11_ricehub)C++17
68 / 100
1079 ms2480 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define ff first #define ss second ll ttt; const ll INF=1e18; const ll MOD=1e9+7; const ll N=200007; ll n,m,k; ll a[N]; ll calc(int l, int r){ int mid=(l+r)/2; ll val=0; for(int i=l;i<=r;i++){ val+=abs(a[i]-a[mid]); } return val; } int besthub(int R, int L, int X[], ll B){ n=R; m=L; for(int i=0;i<n;i++){ a[i]=X[i]; } k=B; int l=0,r=0; int ans=0; while(l<n&&r<n){ if(calc(l,r)<=k){ ans=max(ans,r-l+1); r++; } else{ l++; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...