# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
54863 | FLDutchman | Rice Hub (IOI11_ricehub) | C++14 | 68 ms | 3452 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"
#include "ricehub.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
vi prefix, suffix;
vi rice;
ll MAX;
ll cost(ll l, ll r){
ll m = (l+r)/2;
ll c = prefix[r] - prefix[m] - rice[m] * (r-m);
c += suffix[l] - suffix[m] - (MAX - rice[m]) * (m-l);
return c;
}
bool possible(int l, int r, ll B){
//cout <<l << " " << r << " " << cost(l,r) << endl;
return cost(l, r) <= B;
}
int besthub(int R, int L, int X[], ll B)
{
MAX = L;
rice.resize(R);
for(int i = 0; i < R; i++) rice[i] = X[i];
prefix.assign(R+1, 0); suffix.assign(R+1, 0);
# | 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... |