# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1188293 | alwaus424 | Knapsack (NOI18_knapsack) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
#define fr(n) for (int i = 0; i < n; i++)
typedef long long ll;
void always424() {
int s, n;
cin >> s >> n;
vector<tuple<int, int, int>> v(n);
fr(n) {
int a, b, c;
cin >> a >> b >> c;
v[i] = make_tuple(a, b, c);
}
ll tot = 1;
ll ans = 0;
int cost = get<0>(v[0]);
int weight = get<1>(v[0]);
int quantity = get<2>(v[0]);
while (tot <= s && quantity > 0) {
tot += weight;
ans += cost;
quantity--;
}
cout << ans << '\n';
}