SSOJ 1320.买装备


题目:

传送门


题意:

给出每个装备的所有信息,求在满足物抗呵魔抗的最低要求时,要花费的最小价钱


分析:

因为数据十分小,所以愉快暴力 d f s dfs dfs切掉


代码:

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#define LL long long 
#define LZX 100000007
inline LL read() {
    LL d=0,f=1;char s=getchar();
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
    while(s>='0'&&s<='9'){d=d*10+s-'0';s=getchar();}
    return d*f;
}
using namespace std;
struct node{
	int a,b,w;
}x[25];
int a=read(),b=read();
int n=read();
int ans;
void dfs(int i,int s1,int s2,int m)
{
	if(i>n)
	{
		if(s1>=a&&s2>=b) ans=min(ans,m);
		return;
	}
	dfs(i+1,s1+x[i].a,s2+x[i].b,m+x[i].w);
	dfs(i+1,s1,s2,m);
	return;
}
int main()
{
	for(int i=1;i<=n;i++) x[i]=(node){read(),read(),read()};
	ans=2147483647/3;
	dfs(1,0,0,0);
	cout<<ans;
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值