题目
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(1≤a≤100000) — the number of ties.
The second line contains one integer b ( 1 ≤ b ≤ 100000 ) b (1\leq b\leq 100000) b(1≤b≤100000) — the number of scarves.
The third line contains one integer c ( 1 ≤ c ≤ 100000 ) c (1\leq c\leq 100000) c(1≤c≤100000) — the number of vests.
The fourth line contains one integer d ( 1 ≤ d ≤ 100000 ) d (1\leq d\leq 100000) d(1≤d≤100000) — the number of jackets.
The fifth line contains one integer e ( 1 ≤ e ≤ 1000 ) e (1\leq e\leq 1000) e(1≤e≤1000) — 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(1≤f≤1000) — 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;
}