# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1108324 | expert007 | Knapsack (NOI18_knapsack) | C++14 | 0 ms | 0 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.
void solve() {
int s, n;
cin >> s >> n;
vector<int> v(n), w(n), k(n);
for (int i = 0; i < n; i++) {
cin >> v[i] >> w[i] >> k[i];
}
if (n == 1) {
int maxi = 0;
for (int i = 1; i <= k[0]; i++) {
int total_weight = w[0] * i;
int total_value = v[0] * i;
if (total_weight <= s) {
maxi = max(maxi, total_value);
} else {
break;
}
}
cout << maxi << endl;
}
}