Submission #260652

#TimeUsernameProblemLanguageResultExecution timeMemory
260652youssefbou62Boxes with souvenirs (IOI15_boxes)C++14
0 / 100
0 ms256 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[]) { ll ans = 0 , last = 0 ; int m = N,split=0; for(int i = 0 ; i < N ;i++ ) if( p[i] > L/2 ){ m = i ; if( i ) split = (p[i]-p[i-1])*2 > L ; break ; } int l = -1 ; for(int i = 0 ; i < N ; i++ ){ if( i == m && split )break ; if(i%K==0||i==N-1||(split&&i==m-1)){ ans += min(abs(L-last),last); last = 0 ; l = i ; if( i >= m )break ; } ans += abs(last-p[i]); last = p[i] ; } // cout << ans << " " << l << endl; for(int i = N-1 ; i >= l ; i-- ){ if((N-i)%K==0 || i == l ){ ans += (L-p[i])*2 ; } } // cout << ans << endl; 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...