# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
800709 | firewater | Boxes with souvenirs (IOI15_boxes) | C++14 | 42 ms | 9916 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 <stdio.h>
#include <stdlib.h>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
#define N 100100
ll n,k,ans,x,len,a[N],b[N];
ll solve1(ll x)
{
ll num=0;
while(x-k+1>=1)
{
num+=min(a[x]*2,len);
x-=k;
}
if(x<1)return num;
else return num+min(a[x]*2,len);
}
ll solve2(ll x)
{
ll now=n+1,num=0;
while(x+k-1<=n)
{
num+=min((len-a[x])*2,len);
x+=k;
}
if(x>n)return num;
else return num+min((len-a[x])*2,len);
}
long long delivery(int NN, int K, int L, int ppp[]) {
n=NN;
k=K;
len=L;
for(ll i=1;i<=n;++i)
a[i]=ppp[i-1];
ans=solve1(n);
for(ll i=0;i<=n;++i){
ans=min(ans,solve1(i)+solve2(i+1));
// printf("%lld %lld %lld\n",i,solve1(i),solve2(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... |