# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
961909 | Bee_R | Knapsack (NOI18_knapsack) | C++17 | 101 ms | 262144 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>
#define int long long
#define f cin
#define g cout
using namespace std;
/*ifstream f("knap.in");
ofstream g("knap.out");*/
vector<vector<int>> used;
vector<int> dp, weight, value;
int s, n, result;
int32_t main(){
f>>s>>n;
used.resize(s+1,vector<int>(n+1,0));
weight.resize(n+1);
value.resize(n+1);
for(int i=1;i<=n;i++){
f>>value[i]>>weight[i]>>used[0][i];
}
dp.resize(s+1,0);
for(int i=1;i<=s;i++){
int mx=0, mxv=0;
for(int j=1;j<=n;j++){
int k=i-weight[j];
if(k>=0 && dp[k]+value[j]>mxv && used[k][j]>0){
mx=j;
mxv=dp[k]+value[j];
}
# | 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... |