2962021-08-20 17:17:09Babják PéterBefektetéscpp11Runtime error 0/401ms1212 KiB
#include <bits/stdc++.h>
#define N 4010
using namespace std;
struct d
{
	int a,e,t;	
};
struct cmp
{
	bool operator()(const d &p, const d &q)
	{
		return p.t<q.t;
	}	
};
int dp[N][N];
int atdp[N][N];
signed main()
{
	int n,k;
	cin>>n>>k;
	vector<d>h(n);
	for(int i=0;i<n;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		h[i].a=a;
		h[i].e=b;
		h[i].t=c;
	}
	sort(h.begin(),h.end(),cmp());
	for(int i=1;i<=k;i++)
	{
		int z;
		for(int j=1;j<=n;j++)
		{
			z=i-h[j-1].a;
			if(z>=0) atdp[i][j]=max(atdp[i][j-1],atdp[z][j-1]+h[j-1].e);
			else atdp[i][j]=atdp[i][j-1];
		}
	}
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=n;j++)
		{
			
			int z=i-h[j-1].a-h[j-1].t;
			
			if(z>=0) dp[i][j]=max(dp[i][j-1],atdp[z][j-1]+h[j-1].e);
			else dp[i][j]=dp[i][j-1];
		}
	}
	
	cout<<dp[k][n];
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Runtime error0/01ms1056 KiB
2Runtime error0/01ms1156 KiB
3Runtime error0/21ms1144 KiB
4Runtime error0/21ms1148 KiB
5Runtime error0/11ms1200 KiB
6Runtime error0/21ms1208 KiB
7Runtime error0/21ms1212 KiB
8Runtime error0/21ms1208 KiB
9Runtime error0/21ms1208 KiB
10Runtime error0/21ms1212 KiB
11Runtime error0/31ms1080 KiB
12Runtime error0/31ms1208 KiB
13Runtime error0/31ms1208 KiB
14Runtime error0/31ms1084 KiB
15Runtime error0/31ms1212 KiB
16Runtime error0/41ms1208 KiB
17Runtime error0/11ms1148 KiB
18Runtime error0/11ms1144 KiB
19Runtime error0/11ms1148 KiB
20Runtime error0/11ms1144 KiB
21Runtime error0/11ms1140 KiB
22Runtime error0/11ms1144 KiB