# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
141113 | tincamatei | Journey (NOI18_journey) | C++14 | 145 ms | 11128 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 MAX_N = 10000;
const int MAX_M = 400;
const int INF = 500000001;
vector<pair<int, int> > graph[MAX_N];
int dp[MAX_M][MAX_N];
int sp[MAX_M][MAX_N];
int main() {
int n, m, h;
scanf("%d%d%d", &n, &m, &h);
for(int i = 0; i < n - 1; ++i) {
for(int j = 0; j < h; ++j) {
int to, sl;
scanf("%d%d", &to, &sl);
if(i < to)
graph[to].push_back({i, sl});
}
}
for(int i = 0; i < m; ++i)
sp[i][0] = 1;
dp[0][0] = 1;
for(int i = 0; i < m; ++i)
for(int j = 1; j < n; ++j) {
for(auto it: graph[j])
if(it.second <= i)
dp[i][j] = min(INF, dp[i][j] + sp[i - it.second][it.first]);
if(i > 0)
sp[i][j] = sp[i - 1][j];
sp[i][j] = min(INF, sp[i][j] + dp[i][j]);
}
for(int i = 0; i < m; ++i)
printf("%d ", dp[i][n - 1]);
return 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... |