#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1005;
int n;
struct node{
ll w,s,v;
}a[N];
ll f[2*10005],ans;
bool cmp(node x,node y)
{
return x.s+x.w <= y.s+y.w;
}
ll Max(ll x,ll y)
{
if(x>=y) return x;
return y;
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
scanf("%lld%lld%lld",&a[i].w,&a[i].s,&a[i].v);
sort(a+1,a+1+n,cmp);
for(int i=1;i<=n;i++)
for(int j=a[i].w+a[i].s;j>=a[i].w;j--)
{
f[j]=Max(f[j],f[j-a[i].w]+a[i].v);
ans=Max(ans,f[j]);
}
printf("%lld\n",ans);
return 0;
}
第六个点RE
感觉数组大小开够了呀
谢谢各位大佬