#include <bits/stdc++.h>
using namespace std;
#define ar array
#define ll long long
const int MAX_N = 1e4 + 1;
const int MAX_M = 4e2 + 1;
const int MAX = 5e8 + 1;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
int n, m, h, dp[MAX_N][MAX_M];
void solve() {
cin >> n >> m >> h;
dp[0][0] = 1;
for (int u = 0; u < n - 1; u++) {
for (int i = 0; i < h; i++) {
int v, t; cin >> v >> t;
if (v <= u) continue;
int s = 0;
for (int j = 0; j + t < m; j++) {
s = min(s + dp[u][j], MAX);
dp[v][j + t] = min(dp[v][j + t] + s, MAX);
}
}
}
for (int i = 0; i < m; i++) cout << dp[n - 1][i] << " ";
cout << "\n";
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "t", stdout);
int tc = 1;
// cin >> tc;
for (int t = 1; t <= tc; t++) {
// cout << "Case #" << t << ": ";
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
60 ms |
17516 KB |
Output is correct |
8 |
Correct |
63 ms |
10860 KB |
Output is correct |
9 |
Correct |
12 ms |
1772 KB |
Output is correct |
10 |
Correct |
69 ms |
2156 KB |
Output is correct |