# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
209386 | DystoriaX | Journey (NOI18_journey) | C++14 | 100 ms | 16236 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;
int n, m, h;
int dp[410][10010];
const int INF = 1e9;
const int MAX = 5 * 1e8 + 1;
int main(){
scanf("%d%d%d", &n, &m, &h);
for(int i = 0; i <= 10000; i++)
for(int j = 0; j <= 400; j++)
dp[j][i] = 0;
dp[0][0] = 1;
for(int i = 0; i < n - 1; i++){
int nxt, t;
for(int j = 0; j < m; j++) dp[j + 1][i] = min(1LL * MAX, 1LL * dp[j + 1][i] + dp[j][i]);
for(int k = 0; k < h; k++){
scanf("%d%d", &nxt, &t);
if(nxt <= i) continue;
for(int j = 0; j <= m; j++){
if(j + t >= m) break;
dp[j + t][nxt] = min(1LL * MAX, 1LL * dp[j + t][nxt] + dp[j][i]);
}
}
// for(int j = 0; j <= m; j++)
// if(dp[j][i] != -1) idx = j;
// if(idx == -1) continue;
// for(int j = 0; j < h; j++){
// scanf("%d%d", &nxt, &t);
// if(t + idx <= m){
// if(dp[t + idx][nxt] == -1) dp[t + idx][nxt] = 0;
// dp[t + idx][nxt] = min(1LL * MAX, 1LL * dp[t + idx][nxt] + dp[idx][i]);
// }
// }
// for(int j = idx; j < m; j++){
// dp[j + 1][i] = min(1LL * MAX, 1LL * dp[j + 1][i] + dp[j][i]);
// }
}
for(int i = 0; i < m; i++){
if(i) printf(" ");
printf("%d", max(dp[i][n - 1], 0));
}
printf("\n");
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... |