Submission #386646

#TimeUsernameProblemLanguageResultExecution timeMemory
386646aarrBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
834 ms196332 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; const int N = 10 * 1000 * 1000 + 5; long long sl[N], sr[N]; long long delivery(int n, int k, int l, int a[]) { sort(a, a + n); // long long s = 0; for (int i = 1; i <= n; i++) { sl[i] = a[i - 1]; if (i - k > 0) { sl[i] += sl[i - k]; } } for (int i = n; i; i--) { sr[i] = l - a[i - 1]; if (i + k <= n) { sr[i] += sr[i + k]; } } // for (int i = 0; i <= n; i++) { // cout << "72 " << i << " " << sl[i] << " " << sr[i] << endl; // } long long ans = sl[n] * 2; for (int i = 0; i <= n; i++) { ans = min(ans, (sl[i] + sr[i + 1]) * 2); if (i + k <= n) { ans = min(ans, (sl[i] + sr[i + k + 1]) * 2 + 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...