#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
iostream::sync_with_stdio(false);
cin.tie(nullptr);
int s, n;
cin >> s >> n;
vector<ll> dp(s+1, 0);
for (int i = 0; i<n; i++){
ll a, b, c;
cin >> a >> b >> c;
while (c--){
for (int j = s; j>=b; j--){
if (j==b) dp[j]=max(dp[j], a);
if (dp[j-b]!=0) dp[j]=max(dp[j-b] + a, dp[j]);
}
}
}
ll m = 0;
for (auto i : dp){
m = max(m, i);
}
cout << m << endl;
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... |