# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
67723 | theknife2001 | Boxes with souvenirs (IOI15_boxes) | C++17 | 2 ms | 376 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;
const int N=1e6+55;
bool vis[N];
int n;
long long delivery(int N, int k, int L, int p[])
{
n=N;
int x;
int temp=0;
bool q=0;
long long ans=0;
for(int i=0;i<n;i++)
{
x=k;
temp=0;
while(x--&&i<n)
{
if(p[i]==0)
{
vis[i]=1;
i++;
}
if(p[i]-temp<=L-(p[i]-temp))
{
temp=p[i];
vis[i]=1;
i++;
}
else
{
q=1;
break;
}
}
i--;
ans+=temp+min(temp,L-temp);
if(q)
break;
}
for(int i=n-1;i>=0&&vis[i]==0;i--)
{
x=k;
temp=0;
if(vis[i])
break;
while(x--&&!vis[i]&&i<n)
{
temp=p[i];
i--;
}
i++;
ans+=L-temp+L-temp;
}
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... |