Submission #716582

#TimeUsernameProblemLanguageResultExecution timeMemory
716582Jarif_RahmanRice Hub (IOI11_ricehub)C++17
0 / 100
16 ms2508 KiB
#include "ricehub.h" #include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; int besthub(int n, int L, int X[], long long B){ vector<ll> pref(n, 0); for(int i = 0; i < n; i++){ if(i) pref[i] = pref[i-1]; pref[i]+=X[i]; } auto sum = [&](int l, int r){ return pref[r]-(l?pref[l-1]:0); }; int ans = 0; for(int i = 0; i < n; i++){ int c = min(i, n-i-1); int a = 1, b = c; while(a < b){ int md = (a+b+1)/2; if(sum(i+1, i+c)-sum(i-c, i-1) <= B) a = md; else b = md-1; } if(c == 0) a = 0; if(sum(i+1, i+a)-sum(i-a, i-1) <= B) ans = max(ans, 2*a+1); if(i+a+1 < n && sum(i+1, i+a+1)-sum(i-a, i-1)-X[i] <= B) ans = max(ans, 2*a+2); } 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...