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 ll long long
using namespace std;
const int mxN = 1e5 + 5 , mxS = 2000 + 5;
int n,s;
int v[mxN] , w[mxN] , k[mxN];
ll dp[mxS];
int main(){
ios::sync_with_stdio(0),cin.tie(0);
cin>> s >> n;
for(int i=1;i<=n;i++) cin>> v[i] >> w[i] >> k[i] , k[i] = min(k[i] , s/w[i]);
for(int i=1;i<=n;i++){
for(int j=1;j<=k[i];j++){
for(int cap=s;cap>=w[i];cap--){
dp[cap] = max(dp[cap] , dp[cap - w[i]] + v[i]);
}
// printf("%d %d %d\n",i,j,dp[s]);
}
}
cout<< dp[s];
return 0;
}
# | 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... |