제출 #968606

#제출 시각아이디문제언어결과실행 시간메모리
968606alex_2008선물상자 (IOI15_boxes)C++14
100 / 100
494 ms250528 KiB
#include "boxes.h" #include <iostream> #include <vector> #include <algorithm> typedef long long ll; using namespace std; ll delivery(int n, int k, int l, int pos[]) { vector <int> a, b; vector <ll> dp_a, dp_b; for (int i = 0; i < n; i++) { if (pos[i] <= (l / 2)) a.push_back(pos[i]); else b.push_back(pos[i]); } reverse(b.begin(), b.end()); for (auto &it : b) { it = l - it; } dp_a.resize((int)a.size()); dp_b.resize((int)b.size()); for (int i = 0; i < (int)dp_a.size(); i++) { if (i < k) { dp_a[i] = 2 * a[i]; } else { dp_a[i] = dp_a[i - k] + 2 * a[i]; } } for (int i = 0; i < (int)dp_b.size(); i++) { if (i < k) { dp_b[i] = 2 * b[i]; } else { dp_b[i] = dp_b[i - k] + 2 * b[i]; } } int ind1 = 0, ind2 = 0; ll ans = (((int)dp_a.size() > 0) ? dp_a.back(): 0) + (((int)dp_b.size() > 0) ? dp_b.back(): 0); for (int i = 0; i < (int)dp_a.size(); i++) { ll cur = 0; if (i) cur += dp_a[i - 1]; int mnac = (int)dp_a.size() - i; cur = cur + (mnac + k - 1) / k * 1ll * l; int w = ((mnac + k - 1) / k) * k + i; if (w < (int)dp_a.size() + (int)dp_b.size()) { cur += dp_b[(int)dp_b.size() + (int)dp_a.size() - w - 1]; } ans = min(ans, cur); } return ans; } /* int main() { int n, k, l; cin >> n >> k >> l; vector <int> v(n); for (auto &it : v) { cin >> it; } cout << delivery(n, k, l, v) << "\n"; }*/

컴파일 시 표준 에러 (stderr) 메시지

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:36:6: warning: unused variable 'ind1' [-Wunused-variable]
   36 |  int ind1 = 0, ind2 = 0;
      |      ^~~~
boxes.cpp:36:16: warning: unused variable 'ind2' [-Wunused-variable]
   36 |  int ind1 = 0, ind2 = 0;
      |                ^~~~
#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...