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>
#define ll long long
using namespace std;
ll delivery(int n, int k, int l, int p[])
{
int x=0,y=n-1;
ll ans=0;
while (x<=y)
{
if (y-x+1<=k)
{
ans+=min({l,p[y]*2,(l-p[x])*2});
break;
}
if (p[x+k-1]*2<(l-p[y-k+1])*2)
{
ans+=min(l,p[x+k-1]*2);
x+=k;
}
else
{
ans+=min(l,p[l-y+k-1]*2);
y-=k;
}
}
return ans;
}
// int main()
// {
// int n,k,l;
// cin>>n>>k>>l;
// int p[n];
// for (int i=0;i<n;++i)
// cin>>p[i];
// cout<<delivery(n,k,l,p);
// }
# | 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... |