제출 #1313468

#제출 시각아이디문제언어결과실행 시간메모리
1313468ChaterKnapsack (NOI18_knapsack)C++20
0 / 100
1095 ms332 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
const ll inf = -1e16;
#define sc second
#define fr first
#define all(x) x.begin(),x.end()
#define roll(x) x.rbegin(),x.rend()
#define pb push_back
#define el '\n'
const ll mod = 1e9 + 7;
void solve() {
	ll n,k;cin >> n >> k;
	vector<ll> dp(k+1,-inf);
	dp[0] = 0;
	while(n--){
		ll v,w,s;cin >> v >> w >> s;
		for(ll t = 0;t<s;t++){
			for(ll i = k;i>=v;i--){
				dp[i] = max(dp[i],dp[i-v] + w);
			}
		}
	}
	cout << dp[k];
}
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*ll t;cin >>t;
    while (t--)*/solve();

    return 0;
};
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...