Submission #392410

#TimeUsernameProblemLanguageResultExecution timeMemory
392410HazemRice Hub (IOI11_ricehub)C++14
100 / 100
17 ms3292 KiB
#include <bits/stdc++.h> using namespace std; #define S second #define F first #define LL long long const int N = 2e5+10; const LL MOD = 1e9+7; const LL LINF = 1e18; const LL INF = 1e9; LL a[N],pr[N]; int besthub(int R, int L, int X[], long long B) { int n = R; for(int i=1;i<=n;i++) a[i] = X[i-1],pr[i] = pr[i-1]+a[i]; int l = 1,r = 1,ans = 0; while(r<=n){ int mid = (l+r)/2; LL cost = pr[r]-pr[mid-1]-(r-mid+1)*a[mid]+a[mid]*(mid-l+1)-pr[mid]+pr[l-1]; if(cost<=B) ans = max(ans,r-l+1),r++; else l++; } return ans; } /* #define MAX_R 1000000 static int R, L; static long long B; static int X[MAX_R]; static int solution; inline void my_assert(int e) {if (!e) abort();} static void read_input() { int i; my_assert(3==scanf("%d %d %lld",&R,&L,&B)); for(i=0; i<R; i++) my_assert(1==scanf("%d",&X[i])); my_assert(1==scanf("%d",&solution)); } int main() { int ans; read_input(); ans = besthub(R,L,X,B); if(ans==solution) printf("Correct.\n"); else printf("Incorrect. Returned %d instead of %d.\n",ans,solution); return 0; } */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...