제출 #1007095

#제출 시각아이디문제언어결과실행 시간메모리
1007095The_Samurai선물상자 (IOI15_boxes)C++17
10 / 100
1 ms600 KiB
#include "boxes.h" #include "bits/stdc++.h" using namespace std; using ll = long long; ll delivery(int n, int k, int L, int p[]) { auto dist = [&](int i, int j) -> int { return min(abs(i - j), L - abs(i - j)); }; sort(p, p + n); vector<ll> pref(n), suff(n + 1); int left = 0; bool nw = true; for (int i = 0; i < n; i += k) { for (int j = i; j < min(n, i + k); j++) { pref[j] = i > 0 ? pref[i - 1] : 0; pref[j] += p[j] + dist(0, p[j]); } } for (int i = n - 1; i >= 0; i -= k) { for (int j = i; j >= max(0, i - k + 1); j--) { suff[j] = suff[j + 1]; suff[j] += (L - p[j]) + dist(0, p[j]); } } ll ans = min(pref[n - 1], suff[0]); for (int i = 1; i < n; i++) { ans = min(ans, pref[i - 1] + suff[i]); } return ans; }

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

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:12:9: warning: unused variable 'left' [-Wunused-variable]
   12 |     int left = 0;
      |         ^~~~
boxes.cpp:13:10: warning: unused variable 'nw' [-Wunused-variable]
   13 |     bool nw = true;
      |          ^~
#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...