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;
long long delivery(int n, int k, int L, int p[])
{
long long ans=0;
long long l=0;
long long r=n-1;
while(true)
{
if(l>=r)break;
long long mi1=2e9;
long long a=l+k-1;
if(a<=r)
{
mi1=min(2*p[a], L);
}
long long mi2=2e9;
long long b=r-k+1;
if(b>=l)
{
mi2=min(2*(n-p[b]-1), L);
}
if(mi1<=mi2)
{
ans+=mi1;
l=a;
}
else if(mi1>mi2)
{
ans+=mi2;
r=b;
}
}
return ans;
}
# | 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... |