Submission #260605

#TimeUsernameProblemLanguageResultExecution timeMemory
260605youssefbou62Boxes with souvenirs (IOI15_boxes)C++14
0 / 100
1 ms384 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...