#include <iostream>
#include <vector>
using namespace std;
const int MAXN = 1010;
int dp[MAXN][MAXN];
vector<pair<int,int>> v1[MAXN];
int main(){
int n,m,h;
cin>>n>>m>>h;
for(int i=1;i<n;i++){
for(int j=1;j<=h;j++){
int x,y;
cin>>x>>y;
v1[x+1].push_back(make_pair(i,y));
if(i==1){
dp[x+1][y]++;
}
}
}
for(int i=2;i<=n;i++){
for(int k=0;k<=m;k++){
if(k){
dp[i][k] += dp[i][k-1];
}
for(auto x:v1[i]){
if(k-x.second>=0 && x.first!=1){
dp[i][k]+=dp[x.first][k-x.second];
dp[i][k] = min(dp[i][k],500000000);
}
}
}
}
for(int i=0;i<m;i++){
cout<<dp[n][i]<<" ";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |