#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ent "\n"
const int maxn = 1e4 + 100;
const ll INF = (ll)1e18 + 100;
const int inf = 1e9 + 100;
const int MOD = 1e9 + 7;
const int maxl = 30;
const int P = 31;
int n, m, h;
int dp[maxn][404];
void test(){
cin >> n >> m >> h;
dp[1][0] = 1;
for(int i = 1; i < n; i++){
for(int j = 0; j < h; j++){
int a, b; cin >> a >> b;
a++; if(a <= i) continue;
for(int x = 0; x + b < m; x++){
dp[a][x + b] = min((int)5e8 + 1, dp[a][x + b] + dp[i][x]);
}
}
for(int x = 1; x < m; x++){
dp[i+1][x] = min(int(5e8) + 1, dp[i+1][x] + dp[i+1][x-1]);
}
}
for(int x = 0; x < m; x++){
cout << dp[n][x] << ' ';
}
}
// 4 11 3
// 1 0 2 0 3 0
// 0 0 2 0 3 0
// 0 0 0 0 3 0
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t = 1; t = 1;
while(t--) test();
cout << ent;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
464 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
464 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
36 ms |
17780 KB |
Output is correct |
8 |
Correct |
30 ms |
10836 KB |
Output is correct |
9 |
Correct |
8 ms |
1624 KB |
Output is correct |
10 |
Correct |
32 ms |
2140 KB |
Output is correct |