# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
97382 | Shafin666 | Rice Hub (IOI11_ricehub) | C++14 | 27 ms | 3056 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.
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<ll, ll>
#define to second
#define cost first
typedef long long ll;
typedef long double ld;
using namespace std;
ll besthub(int r, int l, int x[], ll b) {
ll answer = 0;
ll inf = 1e9+7, maxlen = -1;
//sort(x, x+r);
ll c = x[r/2];
vector<ll> v;
for(ll i = 0; i < r; i++) v.pb(abs(x[i]-c));
ll substart = 0, subend = 0;
ll sum = 0;
for(ll i = 0; i < r; i++) {
sum += v[i];
subend++;
while(sum > b) {
sum -= v[substart++];
}
maxlen = max(maxlen, subend-substart);
}
if(r<3) return maxlen;
c = x[(r+1)/2];
v.clear();
for(ll i = 0; i < r; i++) v.pb(abs(x[i]-c));
substart = 0, subend = 0;
sum = 0;
for(ll i = 0; i < r; i++) {
sum += v[i];
subend++;
while(sum > b) {
sum -= v[substart++];
}
maxlen = max(maxlen, subend-substart);
}
return maxlen;
}
/*
int main()
{
int x[1] = {1};
cout << besthub(1, 20, x, 6) << endl;
return 0;
}*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |