A - Suits(Codeforces1271A)

题目

A new delivery of clothing has arrived today to the clothing store. This delivery consists of a a a ties, b b b scarves, c c c vests and d d d jackets.

The store does not sell single clothing items — instead, it sells suits of two types:

  • a suit of the first type consists of one tie and one jacket;
  • a suit of the second type consists of one scarf, one vest and one jacket.

Each suit of the first type costs e e e coins, and each suit of the second type costs f f f coins.

Calculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).

Input
The first line contains one integer a ( 1 ≤ a ≤ 100000 ) a (1\leq a\leq 100000) a(1a100000) — the number of ties.

The second line contains one integer b ( 1 ≤ b ≤ 100000 ) b (1\leq b\leq 100000) b(1b100000) — the number of scarves.

The third line contains one integer c ( 1 ≤ c ≤ 100000 ) c (1\leq c\leq 100000) c(1c100000) — the number of vests.

The fourth line contains one integer d ( 1 ≤ d ≤ 100000 ) d (1\leq d\leq 100000) d(1d100000) — the number of jackets.

The fifth line contains one integer e ( 1 ≤ e ≤ 1000 ) e (1\leq e\leq 1000) e(1e1000) — the cost of one suit of the first type.

The sixth line contains one integer f ( 1 ≤ f ≤ 1000 ) f (1\leq f\leq 1000) f(1f1000) — the cost of one suit of the second type.

Output
Print one integer — the maximum total cost of some set of suits that can be composed from the delivered items.

思路

很明显这两张类型的西装都需要一件夹克,而其他的物品都不相同,所以我们只需要贪心的取价值最大的套装就好,如果还有剩下的夹克再去取另一种类型。
AC代码

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e6+10;
int main()
{
	int a,b,c,d,e,f;
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	LL ans=0LL;
	if(e>f)
	{
		ans=(LL)e*min(a,d);
		d-=min(a,d);
		ans+=(LL)f*min({b,c,d});
	}
	else
	{
		ans=(LL)f*min({b,c,d});
		d-=min({b,c,d});
		ans+=(LL)e*min(a,d);
	}
	printf("%lld\n",ans);
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值