# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
586400 |
2022-06-30T08:25:52 Z |
Jomnoi |
Journey (NOI18_journey) |
C++17 |
|
59 ms |
19492 KB |
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 10005;
const int MAX_M = 405;
const int MOD = 500000001;
int dp[MAX_N][MAX_M];
vector <pair <int, int>> graph[MAX_N];
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int N, M, H;
cin >> N >> M >> H;
for(int i = 0; i < N - 1; i++) {
for(int h = 0; h < H; h++) {
int j, k;
cin >> j >> k;
if(i < j) {
graph[i].emplace_back(j, k);
}
}
}
dp[0][0] = 1;
for(int i = 0; i < N - 1; i++) {
for(int m = 1; m < M; m++) {
dp[i][m] += dp[i][m - 1];
dp[i][m] = min(dp[i][m], MOD);
}
for(auto [j, k] : graph[i]) {
for(int m = 0; m + k < M; m++) {
dp[j][m + k] += dp[i][m];
dp[j][m + k] = min(dp[j][m + k], MOD);
}
}
}
for(int m = 0; m < M; m++) {
cout << dp[N - 1][m] << ' ';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
564 KB |
Output is correct |
5 |
Correct |
1 ms |
704 KB |
Output is correct |
6 |
Correct |
1 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
564 KB |
Output is correct |
5 |
Correct |
1 ms |
704 KB |
Output is correct |
6 |
Correct |
1 ms |
724 KB |
Output is correct |
7 |
Correct |
56 ms |
19492 KB |
Output is correct |
8 |
Correct |
51 ms |
12132 KB |
Output is correct |
9 |
Correct |
11 ms |
2088 KB |
Output is correct |
10 |
Correct |
59 ms |
3068 KB |
Output is correct |