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 <algorithm>
#include <bits/stdc++.h>
#include <cstring>
using namespace std;
const int mod=1e9+7;
int dp[100001][2001],s,n,v[100001],w[100001],k[100001];
int main(){
cin.tie(0)->sync_with_stdio(0);
cin >> s >> n;
for(int i=1;i<=n;i++)
cin >> v[i] >> w[i] >> k[i];
for(int i=1;i<=n;i++){
for(int j=0;j<=s;j++){
for(int t=0;t<=k[i];t++){
if(j>=t*w[i])
dp[i][j]=max(dp[i][j],dp[i-1][j-t*w[i]]+t*v[i]);
}
}
}
cout << dp[n][s];
}
# | 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... |