# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
511223 | AdamGS | Boxes with souvenirs (IOI15_boxes) | C++14 | 501 ms | 224904 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>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
long long delivery(int N, int K, int L, int V[]) {
ll n=N, k=K, l=L, T[n], ans=0;
rep(i, n) T[i]=V[i];
int p=0;
while(p<n && T[p]<=l/2) ++p;
for(int i=p-1; i>=0; i-=k) ans+=2*T[i];
for(int i=p; i<n; i+=k) ans+=2*(l-T[i]);
ll suf[n+1];
suf[n]=0;
for(int i=n-1; i>=0; --i) {
suf[i]=0;
if(i+k<n) suf[i]=suf[i+k];
if(T[i]>l/2) suf[i]+=2*(l-T[i]);
else if(T[min(i+k-1, n-1)]<=l/2) suf[i]+=2*T[min(i+k-1, n-1)];
else suf[i]+=l;
}
ans=min(ans, suf[0]);
rep(i, k) {
if(T[i]<=l/2) ans=min(ans, 2*T[i]+suf[i+1]);
else ans=min(ans, l+suf[i+1]);
}
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... |