Submission #260626

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