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的更多相关文章

  1. [Codeforces #608 div2]1271D Portals

    Description You play a strategic video game (yeah, we ran out of good problem legends). In this game ...

  2. [Codeforces #608 div2]1271C Shawarma Tent

    Description The map of the capital of Berland can be viewed on the infinite coordinate plane. Each p ...

  3. [Codeforces #608 div2]1272B Blocks

    Description There are nnn blocks arranged in a row and numbered from left to right, starting from on ...

  4. Codeforces #180 div2 C Parity Game

    // Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...

  5. Codeforces #541 (Div2) - E. String Multiplication(动态规划)

    Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...

  6. Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)

    Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...

  7. Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)

    Problem   Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...

  8. Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)

    Problem   Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...

  9. 【Codeforces #312 div2 A】Lala Land and Apple Trees

    # [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...

随机推荐

  1. Pytorch-Faster-RCNN 中的 MAP 实现 (解析imdb.py 和 pascal_voc.py)

    ---恢复内容开始--- MAP是衡量object dectection算法的重要criteria,然而一直没有仔细阅读相关代码,今天就好好看一下: 1. 测试test过程是由FRCN/tools/t ...

  2. Vue系列(六)之常用指令v-model

    v-model 基本使用 修饰符 .trim .number .lazy 前面讲到的插值,其实都是单向绑定,数据变-->视图变.有些元素可以与用户交互,比如input,select等,那么我们希 ...

  3. 【转】十步让你成为一名优秀的Web开发人员

    第一步:学好HTML HTML(超文本标记语言)是网页的核心,因此你首先应该学好它,不要害怕,HTML很容易学习的,但也很容易误用,学懂容易要学精还得费点功夫,但学好HTML是成为Web开发人员的基本 ...

  4. 吴裕雄--天生自然python数据清洗与数据可视化:MYSQL、MongoDB数据库连接与查询、爬取天猫连衣裙数据保存到MongoDB

    本博文使用的数据库是MySQL和MongoDB数据库.安装MySQL可以参照我的这篇博文:https://www.cnblogs.com/tszr/p/12112777.html 其中操作Mysql使 ...

  5. 【剑指Offer面试编程题】题目1355:扑克牌顺子--九度OJ

    题目描述: LL今天心情特别好,因为他去买了一副扑克牌,发现里面居然有2个大王,2个小王(一副牌原本是54张^_^)...他随机从中抽出了5张牌,想测测自己的手气,看看能不能抽到顺子,如果抽到的话,他 ...

  6. Java - 实现双向链表

    熟悉一下Java... package ChianTable; import java.util.Scanner; /** * Created by Administrator on 2018/3/2 ...

  7. apply()、call()、bind()

    在JavaScript中,call.apply和bind是Function对象自带的三个方法,这三个方法的主要作用是改变函数中的this指向.apply和call方法.bind方法都是在特定的作用域中 ...

  8. 问题解决 : MyBatis一对一查询时,打印结果只有一条数据

    问题截图:修改后,结果返回条数正确 问题解决: 因为有重名的列,建议起个别名

  9. uniGUI之新窗口uniForm(19)

    然后 保存,在这里 重命名窗口 //主窗口 调用 // NewForm2.UniForm1.Show() ; //非阻塞 NewForm2.UniForm1.ShowModal();//阻塞 //子窗 ...

  10. Java日期时间API系列11-----Jdk8中java.time包中的新的日期时间API类,使用java8日期时间API重写农历LunarDate

    通过Java日期时间API系列7-----Jdk8中java.time包中的新的日期时间API类的优点,java8具有很多优点,现在网上查到的农历转换工具类都是基于jdk7及以前的类写的,下面使用ja ...