Submission #424420

#TimeUsernameProblemLanguageResultExecution timeMemory
424420SuhaibSawalha1선물상자 (IOI15_boxes)C++17
100 / 100
650 ms340972 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]) { long long ans = 9e18; vector<long long> dp(N), dq(N); for (int i = 0; i < N; ++i) { dp[i] = 2 * p[i]; if (i >= K) { dp[i] = 2 * p[i] + dp[i - K]; } } for (int i = N - 1; ~i; --i) { dq[i] = 2 * (L - p[i]); if (i + K < N) { dq[i] = 2 * (L - p[i]) + dq[i + K]; } } dp.insert(dp.begin(), 0); dq.push_back(0); for (int i = 0; i < N + 1; ++i) { ans = min(ans, dp[i] + dq[i]); } for (int i = 0; i + K - 1 < N; ++i) { ans = min(ans, dp[i] + dq[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...