RE求助
  • 板块AT_dp_x Tower
  • 楼主Green_Bird
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/5/28 20:48
  • 上次更新2024/5/28 22:35:27
查看原帖
RE求助
111243
Green_Bird楼主2024/5/28 20:48
#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
感觉数组大小开够了呀
谢谢各位大佬

2024/5/28 20:48
加载中...