Submission #260593

#TimeUsernameProblemLanguageResultExecution timeMemory
260593youssefbou62Boxes with souvenirs (IOI15_boxes)C++14
10 / 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++ ){ // 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 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...