[Codeforces #608 div2]1271A Suits
Description
A new delivery of clothing has arrived today to the clothing store. This delivery consists of aaa ties,bbb scarves,ccc vests and ddd 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 eee coins, and each suit of the second type costs fff 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≤a≤100000)a(1≤a≤100000) — the number of ties.
The second line contains one integer b(1≤b≤100000)b (1≤b≤100000)b(1≤b≤100000) — the number of scarves.
The third line contains one integer c(1≤c≤100000)c(1≤c≤100000)c(1≤c≤100000) — the number of vests.
The fourth line contains one integer d(1≤d≤100000)d(1≤d≤100000)d(1≤d≤100000) — the number of jackets.
The fifth line contains one integer e(1≤e≤1000)e(1≤e≤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≤f≤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.
题意
给定四种物品数量,有2种组合方式:
aaa和ddd组合,权值为eee
bbb和ccc和ddd组合,权值为fff
思路
我们会发现,两种组合重叠部分为ddd,因此我们比较eee和fff的大小,随后贪心分配即可。
代码
代码中个人习惯,将ddd写成了bbb
#include <cstdio>
using namespace std;
template<typename T>
void read(T &r)
{
static char c; r=0;
for(c=getchar();c>'9'||c<'0';c=getchar());
for(;c>='0'&&c<='9';r=(r<<1)+(r<<3)+(c^48),c=getchar());
}
inline int min(const int &a,const int &b){return a<b?a:b;}
inline int min(const int &a,const int &b,const int &c){return min(min(a,b),c);}
int a,b,c,d,e,f;
int main()
{
read(a);
read(c);
read(d);
read(b);
read(e);
read(f);
int can = min(c,d);
if(e >= f)
{
if(b <= a)
{
printf("%d",e * b);
return 0;
}
else
{
int ans = e * a;
b -= a;
can = min(b,can);
ans += can * f;
printf("%d",ans);
return 0;
}
}
else
{
if(can >= b)
{
printf("%d",b * f);
return 0;
}
else
{
int ans = can * f;
b -= can;
can = min(a,b);
ans += can * e;
printf("%d",ans);
return 0;
}
}
return 0;
}
[Codeforces #608 div2]1271A Suits的更多相关文章
- [Codeforces #608 div2]1271D Portals
Description You play a strategic video game (yeah, we ran out of good problem legends). In this game ...
- [Codeforces #608 div2]1271C Shawarma Tent
Description The map of the capital of Berland can be viewed on the infinite coordinate plane. Each p ...
- [Codeforces #608 div2]1272B Blocks
Description There are nnn blocks arranged in a row and numbered from left to right, starting from on ...
- Codeforces #180 div2 C Parity Game
// Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...
- Codeforces #541 (Div2) - E. String Multiplication(动态规划)
Problem Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...
- Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)
Problem Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...
- Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)
Problem Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...
- Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)
Problem Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...
- 【Codeforces #312 div2 A】Lala Land and Apple Trees
# [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...
随机推荐
- git push的时候报错: Out of memory, malloc failed (tried to allocate 82037333 bytes)
原因:上传的文件过大,这里我上传的文件有10G+所以报了上面的错误 解决方法:依次运行:git config --global pack.threads 1 git,git config --glob ...
- 3_04_MSSQL课程_Ado.Net_.ExcuteReader()(SQLDataReader)
ExcuteNonQuery(); 返回影响的行数 ExcuteSacalar();返回第一行第一列 ExcuteReader(): Reader,指针,指向表的表头.只是指向,数据仍在数据库中. S ...
- Spring注解@Qualifier、@Autowired、@Primary
@Qualifier 1.当一个接口有多个实现类,且均已注入到Spring容器中了,使用@AutoWired是byType的,而这些实现类类型都相同,此时就需要使用@Qualifier明确指定使用那个 ...
- IELTS Writing Task 1: two-chart answer
Thursday, January 09, 2020 The chart below shows the value of one country's exports in various categ ...
- 【PAT甲级】1017 Queueing at Bank (25 分)
题意: 输入两个正整数N,K(N<=10000,k<=100)分别表示用户的数量以及银行柜台的数量,接下来N行输入一个字符串(格式为HH:MM:SS)和一个正整数,分别表示一位用户到达银行 ...
- Mark Grover
https://www.ibm.com/developerworks/cn/data/library/bd-zookeeper/
- nodejs的C++扩展中实现异步回调
在nodejs的官方网站中有关于C++扩展的详细说明,其中包含了从"hello world"到对象封装的一系列示例.其中的“callback”节是关于回调函数的,美中不足的是,这个 ...
- SpringMVC 接收表单数据、数据绑定、解决请求参数中文乱码
接收表单数据有3种方式. 1.使用简单类型接收表单数据(绑定简单数据类型) 表单: <form action="${pageContext.request.contextPath}/u ...
- .Net后台实现微信APP支付
上一节分享了微信小程序支付的后台,这一节来分享一下微信APP支付的后台.微信APP支付和微信小程序差别不大,微信APP支付后台不需要微信登录凭证.后台下单时交易类型(trade_type)不再是&qu ...
- ssh_crm项目
1.代码 https://pan.baidu.com/s/1hudAhA8 密码:c7xu 2.总结 https://pan.baidu.com/s/1o9ArFf0 密码:hteu 3.资料 ht ...