# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
228397 | tushar_2658 | Rice Hub (IOI11_ricehub) | C++14 | 109 ms | 708 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 "ricehub.h"
#include "bits/stdc++.h"
using namespace std;
const int maxn = 100005;
using ll = long long;
int a[maxn];
ll lim;
vector<ll> p;
int n;
int besthub(int R, int L, int X[], long long B)
{
n = R;
lim = B;
p.resize(R);
for(int i = 0; i < R; ++i){
a[i] = X[i];
}
sort(a, a + R);
for(int i = 0; i < R; ++i){
if(i == 0){
p[i] = a[i];
}else {
p[i] = p[i - 1] + a[i];
}
}
int ans = 0;
for(int i = 0; i < n; ++i){
ll mid = a[i];
int l = i, r = i;
ll left = B;
int done = 1;
while(left > 0 && r < n && l >= 0){
ll nxt_l = LLONG_MAX;
if(l > 0){
nxt_l = a[l] - a[l - 1];
}
ll nxt_r = LLONG_MAX;
if(r < n - 1){
nxt_r = a[r + 1] - a[r];
}
if(nxt_l < nxt_r){
done++;
left -= nxt_l;
if(left < 0){
done--;
break;
}
--l;
}else {
done++;
left -= nxt_r;
if(left < 0){
done--;
break;
}
++r;
}
}
ans = max(ans, done);
}
return ans;
}
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... |