Submission #1013284

#TimeUsernameProblemLanguageResultExecution timeMemory
1013284d4xnBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
478 ms331908 KiB
#pragma GCC optimize ("Ofast") #include "boxes.h" #include <bits/stdc++.h> using namespace std; #define ll long long const int N = 10000000; int n, k, l, p[N]; ll dp[2][N]; ll delivery(int NN, int K, int L, int P[]) { n = NN; k = K; l = L; for (int i = 0; i < n; i++) { p[i] = P[i]; } for (int i = 0; i < n; i++) { dp[0][i] = p[i] + min(p[i], l-p[i]) + (i-k >= 0 ? dp[0][i-k] : 0); } ll ans = dp[0][n-1]; for (int i = n-1; i >= 0; i--) { dp[1][i] = l-p[i] + min(l-p[i], p[i]) + (i+k < n ? dp[1][i+k] : 0); ans = min(ans, (i ? dp[0][i-1] : 0) + dp[1][i]); } 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...