# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
897901 | ByeWorld | Boxes with souvenirs (IOI15_boxes) | C++14 | 423 ms | 212280 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 "boxes.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define pb push_back
using namespace std;
typedef pair<ll,ll> pii;
const ll MAXN = 1e7+10;
const ll INF = 2e18+10;
ll n, k, l;
ll a[MAXN];
ll ans = INF, le = -1, ri = -1;
vector <int> vec;
long long delivery(int N, int K, int L, int p[]) {
n = N; k = K; l = L;
for(int i=0; i<n; i++){
a[i+1] = p[i];
if(p[i] <= l/2) le = i+1;
}
for(int i=n; i>=1; i--){
if(p[i] >= l/2) ri = i;
}
//cout << n << ' ' << k << ' ' << a[1] << " p\n";
ll nw = 0, use = le;
if(le==-1) use = ri;
for(int i=max(0ll, use-k); i<=min(n, use+k); i++){ // paling terakhirnya ada di i
nw = 0;
for(int j=i; j>=1; j-=k){
if(a[j] <= l/2) nw += 2*a[j];
else nw += l;
}
for(int j=i+1; j<=n; j+=k){
if(a[j] <= l/2) nw += l;
else nw += 2*(l-a[j]);
}
ans = min(ans, nw);
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |