[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}\),第一次从原 ...
随机推荐
- Web--TypeConverter
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 含有namespace的类型如何访问
下图中包含的String类型,如果想要在别的文件中去访问的话: 1)需要include"ApiClient.hpp" 2)需要使用oatpp::web::client::ApiCl ...
- JS 一次性事件问题
项目的需求就是不能重复提交 是通过click点击事件提交数据,到这里的时候想了很多办法,比如说销毁这个点击事件, 但是这个实现起来是相对比较麻烦的,后面想到了一个相对比较简单的办法 通过推荐判断 JS ...
- Java如何实现序列化,有什么意义?
1.序列化是干什么的? 简单说就是为了保存在内存中的各种对象的状态,并且可以把保存的对象状态再读出来.虽然你可以用你自己的各种各样的方法来保存Object States, 但是Java给你提供一种应该 ...
- A letter for NW RDMA configuration
Dear : If you have to use EMC NW NDMA to backup oracle database and want to see what happen when bac ...
- vue中配置sass(包含vue-cli 3)
目录 vue vue cli 3 老版本的脚手架搭建的项目 版本 安装 不用修改任何配置 vue文件中使用 vue 更新时间: 2018-09-21 vue cli 3 选择 Manually sel ...
- python 中的 赋值 浅拷贝 深拷贝
1.对象的赋值 都是进行对象引用(内存地址)传递,即 b is a ,a 变 b也变 2.浅拷贝 会创建一个新的对象,对于对象中的元素,浅拷贝就只会使用原始元素的引用(内存地址) 当我们使用下面的操作 ...
- redis队列与RabbitMQ队列区别
消息队列(Message Queue)是一种应用间的通信方式,消息发送后可以立即返回,由消息系统来确保消息的可靠传递.消息发布者只管把消息发布到 MQ 中而不用管谁来取,消息使用者只管从 MQ 中取消 ...
- 一个前端博主的nginx+php+mysql的环境搭建
这几天天某的公司给了在下一个需求,让我修改一个后端大佬用PHP写的一个官网,虽然说修改的内容还是很简单,但是毕竟之前还是没接触过PHP,于是开始了漫长的爬坑之旅,话不多说,这次就给大家介绍一下我配置安 ...
- 解题报告:luogu P1144 最短路计数
题目链接:P1144 最短路计数 很简单的一道\(dfs\),然而我又跑了一遍\(dij\)和排序,时间复杂度是\(O(nlog n)\) 注意:\(1\).搜索时向\(dis[j]=dis[cur] ...