# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
397827 | qwerty234 | 선물상자 (IOI15_boxes) | C++14 | 1 ms | 332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
using namespace std;
vector <ll> val_cw, val_ccw, cf_cw, cf_ccw, dp_cw, dp_ccw;
vector <pair<ll, ll>> cw, ccw;
ll s_cw, s_ccw, add, shift_cw, shift_ccw, n_cw, n_ccw, n, k;
ll ans_cw, ans_ccw, ans, l;
void process_cw(ll k) {
dp_cw.assign(s_cw + 1, 0);
ll cur = 0;
dp_cw[cur] = ans_cw;
for (ll i = n_cw - 1; i >= 0; i--) {
while (cw[i].se > 0) {
cw[i].se--; cur++;
s_cw--;
shift_cw = (shift_cw + 1) % k;
ans_cw -= val_cw[shift_cw];
dp_cw[cur] = ans_cw;
}
val_cw[shift_cw] -= cf_cw[i];
}
}
void process_ccw(ll k) {
dp_ccw.assign(s_ccw + 1, 0);
ll cur = 0;
dp_ccw[cur] = ans_ccw;
for (ll i = n_ccw - 1; i >= 0; i--) {
while (ccw[i].se > 0) {
ccw[i].se--; cur++;
s_ccw--;
shift_ccw = (shift_ccw + 1) % k;
ans_ccw -= val_ccw[shift_ccw];
dp_ccw[cur] = ans_ccw;
}
val_ccw[shift_ccw] -= cf_ccw[i];
}
}
// ll delivery(int n, int k, int l, vector <ll> p) {
ll delivery(int n1, int k1, int l1, int p[]) {
ll n = (ll)n1, k = (ll)k1, l = (ll)l1;
add = 0;
cw.clear(); ccw.clear();
for (ll i = 0; i < n; i++) {
if (l % 2 == 0 && p[i] == l / 2) {
add++;
} else if (p[i] <= l / 2 && p[i] != 0) {
if (cw.size() == 0 || cw[cw.size() - 1].fi != p[i])
cw.pb({p[i], 0});
cw[cw.size() - 1].se++;
} else if (p[i] != 0) {
if (ccw.size() == 0 || ccw[ccw.size() - 1].fi != p[i])
ccw.pb({p[i], 0});
ccw[ccw.size() - 1].se++;
}
}
reverse(ccw.begin(), ccw.end());
val_cw.assign(k, 0);
val_ccw.assign(k, 0);
n_cw = cw.size();
n_ccw = ccw.size();
cf_cw.assign(n_cw, 0);
for (ll i = 0; i < n_cw; i++) {
if (i == 0)
cf_cw[i] = cw[i].fi;
else
cf_cw[i] = cw[i].fi - cw[i - 1].fi;
}
cf_ccw.assign(n_ccw, 0);
for (ll i = 0; i < n_ccw; i++) {
if (i == 0)
cf_ccw[i] = l - ccw[i].fi;
else
cf_ccw[i] = ccw[i - 1].fi - ccw[i].fi;
}
ans_cw = ans_ccw = s_cw = s_ccw = shift_cw = shift_ccw = 0;
for (ll i = n_cw - 1; i >= 0; i--) {
s_cw += cw[i].se;
val_cw[s_cw % k] += cf_cw[i];
ans_cw += (ll)((s_cw + k - 1) / k) * (ll)cf_cw[i];
}
for (ll i = n_ccw - 1; i >= 0; i--) {
s_ccw += ccw[i].se;
val_ccw[s_ccw % k] += cf_ccw[i];
ans_ccw += (ll)((s_ccw + k - 1) / k) * (ll)cf_ccw[i];
}
process_cw(k);
process_ccw(k);
ans = ((n + k - 1) / k) * l;
for (ll i = 0; i <= s_cw; i++) {
ll cnt = (i + add + k - 1) / k;
ll tmp = cnt * l, mod = cnt * k - (add + i);
ans = min(ans, 2 * dp_cw[i] + tmp + 2 * dp_ccw[min(mod, s_ccw)]);
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |