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<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
int read(){int x;scanf("%d",&x);return x;}
void print(int x){printf("%d\n",x);}
const int mod=1000000007;
long long pre[10000005],suf[10000005];
long long delivery(int n,int k,int l,int p[])
{
long long res=(1LL<<60);
rep(i,n)
{
if(p[i]<=l-p[i])
{
if(i<k){pre[i]=min(2*p[i],l);}
else{pre[i]=pre[i-k]+min(2*p[i],l);}
}
}
for(int i=n-1;i>=0;i--)
{
if(p[i]>l-p[i])
{
if(i+k-1<n)
{
suf[i]=suf[i+k]+min(2*(l-p[i]),l);
}
else
{
suf[i]=min(2*(l-p[i]),l);
}
}
}
rep(i,n)
{
if(p[i]<=l-p[i])
{
if(i+k-1<n&&p[i+k-1]>l-p[i+k-1])
{
res=min(res,l+(i?pre[i-1]:0)+(i+k-1<n-1?suf[i+k]:0));
}
}
}
return res;
}
Compilation message (stderr)
boxes.cpp: In function 'int read()':
boxes.cpp:7:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
7 | int read(){int x;scanf("%d",&x);return x;}
| ~~~~~^~~~~~~~~
# | 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... |