Submission #1003171

#TimeUsernameProblemLanguageResultExecution timeMemory
1003171hacizadalRice Hub (IOI11_ricehub)C++17
0 / 100
6 ms604 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long #define pll pair<ll, ll> ll p[5005]; pll binary1(ll b, ll e, ll num, ll money) { ll l = b, r = e, ans = 0; while (l <= r){ ll m = (l + r)/2; if (p[m] - p[b-1] - ((m-b+1)*num) <= money){ l = m + 1; ans = money - (p[m] - p[b-1] - ((m-b+1)*num)); } else { r = m - 1; } } return {ans, l-1}; } pll binary2(ll b, ll e, ll num, ll money) { ll l = b, r = e, ans = 0; while (l <= r){ ll m = (l + r)/2; if ((m-b+1)*num - p[m] <= money){ l = m + 1; ans = money - ((m-b+1)*num - p[m]); } else { r = m - 1; } } return {ans, l-1}; } int besthub(int n, int l, int a[], long long b) { for (ll i = 0; i<n; i++){ p[i+1] = p[i] + a[i]; } ll mx = 0; for (ll i = 1; i<=l; i++){ ll x = lower_bound(a, a+n, i) - a; pll k = binary1(x+1, n, i, b); pll g = binary2(1, x, i, b-k.first); mx = max(mx, (k.second-g.second+1)); } return mx; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...