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>
#define ll long long
using namespace std;
long long delivery(int N, int K, int L, int p[]) {
int i = 0 , cnt = 0 ;
ll ans = 0 , last = 0 ;
for( i = 0 ; i< N; i++ ){
if(p[i]>L/2)
break ;
if( cnt == K ){
ans += last;
last = 0LL;
cnt = 0 ;
}
ans += abs(last-1LL*p[i]) ;
last = 1LL*p[i] ;
cnt ++ ;
}
int stop = i ;
if( 2*(p[stop]-p[stop-1])>L){
ans += last ;
cnt = 0 ;
last = L ;
}
for(i=N-1;i>=stop;i--){
if( cnt == K ){
ans += last;
last = 1LL*L;
cnt = 0 ;
}
ans += abs(last-1LL*p[i]) ;
last = 1LL*p[i] ;
cnt ++ ;
}
ans += min({last,abs(1LL*L-last)}) ;
return ans;
}
// int main() {
// int N, K, L, i;
// cin >> N >> K >> L ;
// int p[N] ;
// for (i = 0; i < N; i++) {
// cin >> p[i] ;
// }
// cout << delivery(N,K,L,p);
// return 0;
// }
# | 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... |