# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
888952 | dwuy | Rice Hub (IOI11_ricehub) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/// dwuy: _,\,,,_\,__,\,,_
#include <bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define file(a) freopen(a".inp","r",stdin); freopen(a".out", "w",stdout)
#define fi first
#define se second
#define endl "\n"
#define len(s) int32_t(s.length())
#define MASK(k)(1LL<<(k))
#define TASK ""
using namespace std;
typedef tuple<int, int, int> tpiii;
typedef pair<double, double> pdd;
typedef pair<int, int> pii;
typedef long long ll;
const long long OO = 1e18;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MX = 200005;
ll n, l, money;
ll a[MX];
ll sum[MX];
ll get(ll l, ll r){
return sum[r] - sum[l-1];
}
ll cost(ll l, ll r){
ll mid = (l+r)>>1;
return get(mid+1, r) - get(l, mid - ((r-l+1)&1));
}
int besthub(ll N, ll L, ll X[], ll B){
n = N;
l = L;
money = B;
for(ll i=1; i<=n; i++){
a[i] = X[i-1];
sum[i] = sum[i-1] + a[i];
}
ll ans = 0;
for(ll l=1, r=1; r<=n; r++){
while(cost(l, r)>money) l++;
ans = max(ans, r-l+1);
}
return ans;
}