# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
532030 | nguyentunglam | Boxes with souvenirs (IOI15_boxes) | C++14 | 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<bits/stdc++.h>
#define forin(i, a, b) for(int i = a; i <= b; i++)
#define forde(i, a, b) for(int i = a; i >= b; i--)
#define fi first
#define se second
#define ll long long
using namespace std;
const int N = 1e7 + 10;
int a[N], dp[2][N];
int res = 1e9;
int delivery(int n, int k, int l,int a[])
{
//forin(i, 1, n) cin >> a[i];
forin(i, 1, n) dp[0][i] = dp[0][max(0, i-k)] + a[i] + min(a[i], l-a[i]);
forde(i, n, 1) dp[1][i] = dp[1][min(n+1, i+k)] + l-a[i] + min(a[i], l - a[i]);
forin(i, 1, n+1) res = min(res, dp[0][i-1] + dp[1][i]);
//forde(i, n, 1) cout << dp[1][i]<<" ";
return res;
}
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... |