#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+11, MAXM = 401;
int dp[MAXN][MAXM];
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int N,M,H; cin >> N >> M >> H;
dp[0][0] = 1;
for(int i = 0;i<N-1;++i){
for(int j = 0;j<MAXM-1;++j) dp[i][j+1] = min(dp[i][j+1]+dp[i][j],500000001);
for(int j = 0;j<H;++j){
int x,t; cin >> x >> t;
if(x <= i) continue;
for(int k = 0;k+t<MAXM;++k) dp[x][k+t] = min(dp[i][k]+dp[x][k+t],500000001);
}
}
for(int i = 0;i<M;++i){
cout << dp[N-1][i] << " ";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
93 ms |
18516 KB |
Output is correct |
8 |
Correct |
50 ms |
11904 KB |
Output is correct |
9 |
Correct |
9 ms |
2908 KB |
Output is correct |
10 |
Correct |
39 ms |
3164 KB |
Output is correct |