제출 #386629

#제출 시각아이디문제언어결과실행 시간메모리
386629aarr선물상자 (IOI15_boxes)C++14
20 / 100
2 ms364 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] = s + a[i - 1]; if (i % k == 0) { s += a[i - 1]; } } s = 0; for (int i = n; i; i--) { sr[i] = s + l - a[i - 1]; if (i % k == (n + 1) % k) { s += l - a[i - 1]; } } // 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...