第十一届山东省大学生程序设计竞赛(正式赛) Adventurer‘s Guild

Yuna traveled into the fantasy world. The gods of this world gave her a powerful set of equipment so that she could defeat many fierce monsters. However, she had limited health points and stamina, and she could not kill a large number of monsters.

Adventurer's guild would release nnn monster crusade missions, such as black python and wild wolf. Completing the iii-th mission would consume Yuna hih_ihi​ health points and sis_isi​ stamina, and then she would get wiw_iwi​ gold coins.

In the beginning, Yuna had HHH health points and SSS stamina. When her health points were dropped to less than or equal to 000, she would die. However, when her stamina was dropped to less than 000, she would not give up, and then the overdrawn stamina would be reduced from health points. For example, her health points would be reduced by 333, when her stamina dropped to −3-3−3, and then her stamina would be reset to 000. If her health points can not afford the overdrawn stamina, she would also die.

As a friend of Yuna, can you help her choose some missions to complete to get the maximum number of gold coins? Make sure Yuna does not die, or you will be very sad.

输入描述:

 

The first line contains three integers n,H,Sn,H,Sn,H,S (1≤n≤1000,1≤H≤300,0≤S≤300)(1 \le n \le 1000, 1 \le H \le 300, 0 \le S \le 300)(1≤n≤1000,1≤H≤300,0≤S≤300).

The next nnn lines describe all the monster crusade missions, where the iii-th line contains three integers hi,si,wih_i, s_i, w_ihi​,si​,wi​ (0≤hi,si≤300,1≤wi≤109)(0 \le h_i, s_i \le 300, 1 \le w_i \le 10^9)(0≤hi​,si​≤300,1≤wi​≤109).

输出描述:

Print one integer -- the maximum number of gold coins that Yuna could get.

示例1

输入

复制2 66 22 1 23 2 66 8 90

2 66 22
1 23 2
66 8 90

输出

复制2

2

示例2

输入

复制4 16 22 1 23 11 5 8 14 2 36 99 15 22 27

4 16 22
1 23 11
5 8 14
2 36 99
15 22 27

输出

复制27

27

二位费用简单变式

#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize(2)
#define  endl '\n'
#define lowbit(x) ((x)&-(x))
const int N=2e6+10;
const int mod =998244353;
typedef long long ll;
ll ans=0,n1,m1;
ll t=0,s1=0,s2=0,s3=0,s4=0,max1=0,max2=0,min1=100000000,sum=0,n,m,i,j,k,r,l;

inline int read() {
	bool sym=0;
	int res=0;
	char ch=getchar();
	while(!isdigit(ch))sym |=(ch =='-'),ch=getchar();
	while(isdigit(ch)) res =(res<<3)+(res<<1)+(ch^48),ch=getchar();
	return sym ? -res : res;
}
void print(int x) {
	if(!x)return;
	print(x/10);
	putchar(x%10+'0');
}
int isPrime(int n) {
	float n_sqrt;
	if(n==1) return 0;
	if(n==2 || n==3) return 1;
	if(n%6!=1 && n%6!=5) return 0;
	n_sqrt=floor(sqrt((float)n));
	for(int i=5; i<=n_sqrt; i+=6) {
		if(n%(i)==0 | n%(i+2)==0) return 0;
	}
	return 1;

}
ll dp[1080][1007],v[100086],w[100086],q[100086];
int main() {


	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>l;
	for(i=1; i<=n; i++) {
		cin>>w[i]>>q[i]>>v[i];
		q[i]+=w[i];
	}
	m--;
	ll ss=m+l;
	for(i=1; i<=n; i++) {
		for(k=l+m; k>=q[i]; k--) {
			for(j=m; j>=w[i]; j--) {
				
				dp[k][j]=max(dp[k][j],dp[k-q[i]][j-w[i]]+v[i]);
				
			}
		}
	}
	cout<<dp[ss][m];
	return 0;
}

//mio lover

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值