/**
* author: MINHTPC
*
**/
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin() , a.end()
#define FOR(i ,a , b) for(int i = a ; i <= b ; ++i)
#define bit(mask,i) ((mask>>i)&1)
#define name "task"
#define lo lower_bound
#define up upper_bound
#define count_bit1(x) __builtin_popcountll(x)
#define count_bit01(x) __builtin_clzll(x)
#define count_bit10(x) __builtin_ctzll(x)
using namespace std;
const int N=1e6+5;
long long dp[N],a[N],b[N];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int s,n;
cin >> s >> n;
for(int i=1;i<=n;i++) {
int t;
cin >> a[i] >> b[i] >> t;
}
// long long x=accumulate(a+1,a+n+1,0LL);
for(int i=1;i<=n;i++) {
for(int j=s;j>=b[i];j--) {
dp[j]=max(dp[j],dp[j-b[i]]+a[i]);
}
}
cout << dp[s] << '\n';
}
# | 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... |