203972026-01-06 17:36:20algoproBefektetéscpp17Wrong answer 2/4039ms32768 KiB
// UUID: 1de5e1e2-cac2-4830-9803-9b632d5e99a1
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, k; cin>>n>>k;
	vector<array<int, 3>> l(n+1); //ado, ar, ertek
	for(int i=1; i<=n; i++){
		cin>>l[i][1]>>l[i][2]>>l[i][0];
	}
	sort(l.begin(), l.end());

	vector<vector<int>> dp(n+1, vector<int>(k+1));
	int mx=0;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=k; j++){
			int a=l[i][0]-l[i-1][0];
			if(j-a>=0){dp[i][j]=dp[i-1][j-a];}
			//dp[i][j]=max(dp[i-1][j]+a, 0);
			if(j-a>= l[i][1]){
				dp[i][j]=max(dp[i][j], dp[i-1][j-a-l[i][1]]+l[i][2]);
			}
			mx=max(mx, dp[i][j]);
		}
	}
	cout<<mx;

	/*for(int i=0; i<=n; i++){
		cout<<endl;
		for(int j=0; j<=k; j++){
			cout<<dp[i][j]<<" ";
		}
	}*/
}
SubtaskSumTestVerdictTimeMemory
base2/40
1Accepted0/01ms316 KiB
2Wrong answer0/08ms4148 KiB
3Accepted2/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/11ms316 KiB
6Wrong answer0/21ms572 KiB
7Wrong answer0/21ms428 KiB
8Wrong answer0/21ms564 KiB
9Wrong answer0/21ms564 KiB
10Wrong answer0/21ms564 KiB
11Wrong answer0/324ms16012 KiB
12Wrong answer0/327ms16076 KiB
13Wrong answer0/324ms16040 KiB
14Wrong answer0/327ms15992 KiB
15Wrong answer0/327ms16144 KiB
16Wrong answer0/424ms16164 KiB
17Runtime error0/130ms32768 KiB
18Runtime error0/137ms32768 KiB
19Runtime error0/137ms32768 KiB
20Runtime error0/139ms32768 KiB
21Runtime error0/132ms32768 KiB
22Runtime error0/137ms32768 KiB