Submission #386628

#TimeUsernameProblemLanguageResultExecution timeMemory
386628alireza_kavianiBoxes with souvenirs (IOI15_boxes)C++11
100 / 100
531 ms196204 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; typedef long long ll; const int MAXN = 1e7 + 10; const ll INF = 1e18; ll l[MAXN] , r[MAXN]; long long delivery(int N, int K, int L, int p[]) { for(int i = 0 ; i < N ; i++){ l[i] = p[i] * 2; r[i] = (L - p[i]) * 2; } for(int i = K ; i < N ; i++) l[i] += l[i - K]; for(int i = N - K ; i >= 0 ; i--) r[i] += r[i + K]; ll ans = min(l[N - 1] , r[0]); for(int i = 1 ; i < N ; i++) ans = min(ans , l[i - 1] + r[i]); for(int i = 0 ; i + K <= N ; i++){ ans = min(ans , (i == 0 ? 0 : l[i - 1]) + r[i + K] + L); } return ans; }
#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...