Submission #1127214

#TimeUsernameProblemLanguageResultExecution timeMemory
1127214freedommo33Rice Hub (IOI11_ricehub)C++20
100 / 100
12 ms2376 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; constexpr int M = 100'005; ll tab[M]; ll pref[M]; ll suma(int l, int r){ return pref[r] - pref[l-1]; } int besthub(int n, int L, int X[], long long B){ for(int i=1; i<=n; i++) tab[i] = X[i-1]; for(int i=1; i<=n; i++) pref[i] = pref[i-1] + tab[i]; ll l = 1; ll wynik = 0; for(ll r=1; r<=n; r++){ int mid = (l + r) / 2; ll koszt = tab[mid] * (mid - l + 1) - suma(l+1, mid) - tab[l]; koszt += suma(mid+1, r) - tab[mid] * (r - mid); while(l < r && koszt > B){ l++; koszt = tab[mid] * (mid - l + 1) - suma(l+1, mid) - tab[l]; koszt += suma(mid+1, r) - tab[mid] * (r - mid); } wynik = max(wynik, r - l + 1); } return wynik; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...