[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}\),第一次从原 ...
随机推荐
- 珠心算测验(0)<P2014_1>
珠心算测验 (count.cpp/c/pas) 问题描述] 珠心算是一种通过在脑中模拟算盘变化来完成快速运算的一种计算技术.珠心算训练,既能够开发智力,又能够为日常生活带来很多便利,因而在很多学校得 ...
- vue学习笔记:Hello Vue
编写简单例子,了解下基本语法 <!DOCTYPE html> <html> <head> <meta charset="utf-8 "&g ...
- IVM sdk command
1.load sdk shell ./auto_load_user.sh 2.查看all端口状态 IVM:0>ifcs show devport 3.查看个别端口状态 IVM:0>ifcs ...
- Node Sass does not yet support your current environment: Linux 64-bit with Unsupported runtime
环境: ubuntu18 webstorm vue项目 报错原因: 缺少相关依赖 解决方法: npm rebuild node-sass 还未解决: npm uninstall --save node ...
- JAVA高级编程数据源datasource
原文链接 数据源 通过jdbc连接数据库,多建立几条连接放在数据源里面.可以设置数据源的最大连接数,同时活跃的连接数,最少空闲的连接数,能够同时接收处理的连接数等等. dbcp数据源 需要的jar包: ...
- 1 Struts2基本概述及其入门
什么是Struts2? webwork+Struts1 一个基于MVC设计模式的web层框架,本质上相当于一个Servlet.. 在MVC设计模式中,Struts2作为控制器Controller来建立 ...
- Elasticsearch 如何使用RESTful API
所有其他语言可以使用 RESTful API 通过端口 9200 和 Elasticsearch 进行通信,你可以用你最喜爱的 web 客户端访问 Elasticsearch .事实上,正如你所看到的 ...
- static在c\c++中的作用(翁恺c++公开课[28-29]学习笔记)
static相对来说是一个较复杂的修饰符,c++中的static在c的基础之上又包含了static在类中的应用(也就是说多了static的成员变量和static的成员函数):c\c++中静态变量.对象 ...
- Spring MVC原理解析
SpringMVC Spring MVC的工作原理 ①客户端的所有请求都交给前端控制器DispatcherServlet来处理,它会负责调用系统的其他模块来真正处理用户的请求. ② Dispatche ...
- 如何让tomcat加载项目变快
修改配置: VM options填写内容: -Xms128m -Xmx256m -XX:PermSize=128m -XX:MaxPermSize=256m` 图示: ##1: ##2: