Submission #533621

#TimeUsernameProblemLanguageResultExecution timeMemory
533621__VariattoRice Hub (IOI11_ricehub)C++17
100 / 100
15 ms3304 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; #define pb push_back #define fi first #define se second #define ll long long const ll MAX=1e5+10; ll n, l, b, pref[MAX], t[MAX]; bool spr(ll x){ for(ll i=1; i<=n-x+1; i++){ ll mid=(i+i+x-1)/2; ll lewo=pref[mid-1]-pref[i-1]; ll prawo=pref[i+x-1]-pref[mid]; if((mid-i)*t[mid]-lewo+prawo-(i+x-1-mid)*t[mid]<=b) return true; } return false; } int besthub(int R, int L, int X[], ll B){ n=R, l=L, b=B; for(ll i=1; i<=n; i++){ pref[i]=X[i-1]; t[i]=pref[i]; pref[i]+=pref[i-1]; } ll pocz=1, kon=n, sr, wynik=1; while(pocz<=kon){ sr=(pocz+kon)/2; if(spr(sr)) pocz=sr+1, wynik=sr; else kon=sr-1; } return wynik; } /*ll main(){ ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(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...