# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
67757 | theknife2001 | Boxes with souvenirs (IOI15_boxes) | C++17 | 2 ms | 380 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 "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
const int N=1e7+55;
long long dp[N][2];
int n;
long long delivery(int N, int k, int L, int p[])
{
n=N;
int x;
int temp=0;
bool q=0;
for(int i=0;i<n;i++)
{
x=k;
while(x--&&i<n)
{
dp[i][0]=temp+p[i];
i++;
}
i--;
temp+=p[i]+min(p[i],L-p[i]);
}
temp=0;
for(int i=n-1;i>=0;i--)
{
x=k;
while(x--&&i<n)
{
dp[i][1]=temp+(L-p[i]);
i--;
}
i++;
temp+=L-p[i]+min(p[i],L-p[i]);
}
long long ans=1e18;
for(int i=0;i<n;i++)
{
ans=min(dp[i][0]+(i+1<n?dp[i+1][1]:0)+min(p[i],L-p[i])+(i+1<n?min(p[i+1],L-p[i+1]):0),ans);
}
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... |