# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
750559 | Sami_Massah | Collecting Stamps 3 (JOI20_ho_t3) | C++17 | 17 ms | 37588 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>
using namespace std;
const int maxn = 200 + 12, inf = 1e9 + 12;
int n, L, dist[maxn], t[maxn], dp[maxn][maxn][maxn];
int find_ans(int a, int b, int c){
if(c < 0)
return inf;
if(dp[a][b][c] != -1)
return dp[a][b][c];
// cout << a << ' ' << b << ' ' << c << endl;
dp[a][b][c] = inf;
if(a < b){
if(a != 0){
dp[a][b][c] = min(dp[a][b][c], find_ans(a - 1, b, c) + abs(dist[a] - dist[a - 1]));
int x = find_ans(a - 1, b, c - 1) + abs(dist[a] - dist[a - 1]);
if(x <= t[a])
dp[a][b][c] = min(dp[a][b][c], x);
}
if(a != 0){
dp[a][b][c] = min(dp[a][b][c], find_ans(b, a - 1, c) + abs(L - dist[b]) + dist[a]);
int x = find_ans(b, a - 1, c - 1) + abs(L - dist[b]) + dist[a];
if(x <= t[a])
dp[a][b][c] = min(dp[a][b][c], x);
}
}
else if(a > b){
if(a != n){
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... |