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;
#define pb push_back
#define mp make_pair
#define ll long long
#define itr ::iterator
const int MAX=1e5;
ll N,K,L,sz,start[MAX],finish[MAX];
long long delivery(int N_,int K_, int L_,int P[])
{
N=N_;
K=K_;
L=L_;
for(int A=0;A<N;A+=K)
{
start[A/K]=P[A];
finish[A/K]=P[min(A+K-1,N-1)];
sz++;
}
ll res=0;
for(int A=0;A<sz;A++)
{
//cout<<start[A]<<" "<<finish[A]<<"\n";
res+=min(2*finish[A],min(2*(L-start[A]),L));
}
return res;
}
/*int main()
{
ios_base::sync_with_stdio(false);
int P[]={1,2,5};
cout<<delivery(3,2,8,P)<<"\n";
return 0;
}*/
Compilation message (stderr)
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:19:22: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
for(int A=0;A<N;A+=K)
~^~~
# | 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... |