This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10011, MAXM = 401;
int dp[MAXN][MAXM];
inline int sat_add(int x, int y){
return min(500000001, x + y);
}
int main(){
int n, m, h; cin >> n >> m >> h;
dp[0][0] = 1;
for(int i = 0; i < n - 1; i++){
for(int k = 0; k < MAXM - 1; k++){
dp[i][k + 1] = sat_add(dp[i][k + 1], dp[i][k]);
}
for(int j = 0; j < h; j++){
int v, t; cin >> v >> t;
if(v <= i) continue;
for(int k = 0; k + t < MAXM; k++){
dp[v][k + t] = sat_add(dp[v][k + t], dp[i][k]);
}
}
}
for(int i = 0; i < m; i++){
cout << dp[n - 1][i] << ' ';
}
cout << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |