Submission #969904

#TimeUsernameProblemLanguageResultExecution timeMemory
969904uriegRice Hub (IOI11_ricehub)C++17
0 / 100
2 ms600 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; typedef long long ll; int besthub(int R, int L, int X[], long long B){ vector<ll>x(R), p(R); for(int i=0;i<R;i++){ x[i] = X[i]; p[i] = x[i]; if(i)p[i] += p[i-1]; } int ans = 1; ll sum = 0; int l = 0, r = 0; for(int i =0;i<R;i++){ sum = p[r]-p[i] - p[i]*(r-i); sum += p[i]*(i-l+1) - (p[i]-(!l ? 0 : p[l-1])); while(sum > B){ l++; sum = p[r]-p[i] - p[i]*(r-i); sum += p[i]*(i-l+1) - (p[i]-(!l ? 0 : p[l-1])); } while(r<R){ r++; ll new_sum = p[r]-p[i] - p[i]*(r-i); new_sum += p[i]*(i-l+1) - (p[i]-(!l ? 0 : p[l-1])); if(new_sum <= B)sum = new_sum; else{ r--; break; } } ans = max(ans, r-l+1); } 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...