Submission #250068

#TimeUsernameProblemLanguageResultExecution timeMemory
250068hhh07Boxes with souvenirs (IOI15_boxes)C++14
0 / 100
1 ms384 KiB
#include <iostream> #include <vector> #include <algorithm> #include <queue> #include <utility> #include <set> #include <cmath> #include <climits> #include <cstring> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; int delivery(int n, int k, int l, int pos[]){ vi p(n, 0); sort(pos, pos + n); int dp1[n], dp2[n]; for (int i = 0; i < n; i++){ if (i >= k) dp1[i] = dp1[i - k] + 2*pos[i]; else dp1[i] = 2*pos[i]; } for (int i = n - 1; i >= 0; i--){ if ((n - 1) - i >= k) dp2[(n - 1) - i] = dp2[(n - 1) - i - k] + 2*(l - pos[i]); else dp2[(n - 1) - i] = 2*(l - pos[i]); } int res = INT_MAX; for (int i = 0; i < n; i++){ res = min(res, dp1[i] + dp2[n - i - 2]); if (n - i >= k) res = min(res, dp1[i] + l + dp2[n - i - 2 - k]); } return res; }
#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...