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++ ){
// cout << ans << " " << endl;
if( (i&& 2*(p[i]-p[i-1]) >L )|| cnt == K ){
ans += min({(last),abs(1LL*L-last)});
if(p[i]<=L/2)
last = 0;
else last = L ;
cnt = 0 ;
}
ans += abs(last-p[i]) ;
last = 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... |