# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
976765 | Amaarsaa | Boxes with souvenirs (IOI15_boxes) | C++14 | 1 ms | 608 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "boxes.h"
using namespace std;
using ll = long long ;
ll delivery(int N, int K, int L, int p[]) {
ll ans, cnt_ard, cnt_urd, res;
vector < ll > ard, urd;
ll cnt = 0, i, j, r, s;
for (i = 0; i < N; i ++) {
if ( p[i] * 2 > L) {
ard.push_back(p[i]);
}
else {
if (p[i] * 2 < L) urd.push_back(p[i]);
else cnt ++;
}
}
ans = 0;
reverse(ard.begin(), ard.end());
for (i = urd.size() - 1; i >= K -1; i -= K) ans += (urd[i]);
j = i ;
for (i = ard.size() - 1; i >= K - 1; i -= K) ans += ( L - ard[i]);
r = i ;
ans *= 2;
// cout << ans << endl;
cnt_urd = j + 1;
cnt_ard = r + 1;
// cout << cnt_urd << " " << cnt_ard << endl;
res = ((cnt_ard + cnt_urd + cnt + K - 1) / K) * L;
if ( cnt_ard != 0) {
res = min(res, (((L - ard[r]) * 2) + ((cnt_urd + cnt + K - 1)/K) * L) );
}
if ( cnt_urd != 0) {
res = min(res, (((urd[j]) * 2) + ((cnt_ard + cnt + K - 1)/K) * L) );
}
if ( cnt_ard != 0 && cnt_urd != 0) {
res = min(res, (((L - ard[r]) * 2) + (urd[j] * 2)+ ((cnt + K - 1)/K) * L) );
}
return res + ans;
}
Compilation message (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... |