# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
800590 | happypotato | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 212 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 "boxes.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define ff first
#define ss second
#define pb push_back
int n, k, l;
vector<int> v;
int st1() {
int ans = 0;
for (int i = 1; i <= n; i++) ans += min(l, min(v[i], l - v[i]) * 2);
return ans;
}
int st2() {
int ans = min(l, min(v[n], l - v[1]) * 2);
// ???
// cerr << ans << endl;
return ans;
}
long long delivery(int32_t N, int32_t K, int32_t L, int32_t p[]) {
n = N; k = K; l = L; v.clear(); v.pb(-1);
for (int i = 0; i < n; i++) if (p[i]) v.pb(p[i]);
n = (int)(v.size()) - 1;
if (k == 1) return st1();
if (k == n) return st2();
}
#undef int
/*
subtasks 1-3 trivial
subtask 4 should be O(n^2) left-right dp
*/
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... |