Submission #1003338

#TimeUsernameProblemLanguageResultExecution timeMemory
1003338vjudge1Rice Hub (IOI11_ricehub)C++17
100 / 100
12 ms2680 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; #define ll long long const int N = 1e5 + 5; ll a[N]; int b; int besthub(int n, int L, int X[], ll B){ ll ans = 0; ll pref[N + 1]; pref[0] = 0; for(int i = 0; i < n; ++i) pref[i + 1] = pref[i] + X[i]; if(B >= pref[n]) return n; ll l = 1, r = 1; while(r <= n) { ll mid = (l + r) >> 1; if(ans == n) return n; if( ((X[mid - 1] * (mid - l)) - (pref[mid - 1] - pref[l - 1]) + ((pref[r] - pref[mid]) - (X[mid - 1] * (r - mid)))) <= B) ans = max(ans,r-l+1); else ++l; ++r; } 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...