# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1043681 | suyangban | Knapsack (NOI18_knapsack) | C++14 | 1074 ms | 508 KiB |
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;
int s, n;
int v[100001], w[100001], k[100001];
int dp[2001];
int main(){
scanf("%d%d", &s, &n);
for(int i=1; i<=n; i++){
scanf("%d%d%d", &v[i], &w[i], &k[i]);
}
for(int i=1; i<=n; i++){
for(int kk=0; kk<k[i]; kk++){
for(int j=s; j>=w[i]; j--){
dp[j]=max(dp[j], dp[j-w[i]]+v[i]);
}
}
}
printf("%d", dp[s]);
}
Compilation message (stderr)
# | 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... |