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;
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;
}
# | 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... |