# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
780132 | vjudge1 | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 304 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 pb push_back
#define pii pair<long long, long long>
#define st first
#define nd second
#define sp " "
#define endl "\n"
#define ll long long
const ll INF = 2e18 + 7;
long long delivery(int N, int K, int L, int p[]) {
int n = N, k = K, l = L;
sort(p, p + n);
int pos = 0;
while(pos< n && p[pos] <= L / 2) pos++;
vector<ll> dp(n + 5, INF);
dp[n] = 0;
for (int i = n - 1; i >= 0; i--){
int t1 = min(i + k - 1, pos - 1);
t1 = max(t1, i);
int t2 = min(i + k - 1, n - 1);
int tmp[] = {t1, t2};
for (int l = 0; l < 2; l++){
int j = tmp[l];
ll c = 0;
if (p[j] <= L / 2) c = 2 * p[j];
else if (p[i] >= L / 2) c = 2 * (L - p[i]);
else c = L;
dp[i] = min(dp[i], dp[j + 1] + c);
}
//cout<<i<<sp<<t1<<sp<<t2<<sp<<dp[i]<<endl;
}
return dp[0];
}
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... |