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>
#define int long long
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
int dp[2005];
struct Kn{
int v, w, k;
} kn[100005];
void solve(){
int S, N;
cin >> S >> N;
for(int i =1 ; i <= N; i ++) cin >> kn[i].v >> kn[i].w >> kn[i].k;
dp[0] = 0;
for(int i = 1; i <= N; i ++){
for(int j = 1; j <= kn[i].k; j ++){
for(int l = S; l >= kn[i].w; l --){
dp[l] = max(dp[l], dp[l - kn[i].w] + kn[i].v);
}
}
}
cout << dp[S];
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
solve();
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |