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. robot framework 如何自己写模块下的方法或者库

    一.写模块(RF能识别的模块) 例如:F:\Python3.4\Lib\site-packages\robot\libraries这个库(包)下面的模块(.py),我们可以看下源码 注意:这种是以方法 ...

  2. WebService-CXF 学习笔记

    什么是CXF Apache CXF = Celtix + Xfire支持多种协议:SOAP1.1,1.2XML/HTTPCORBA(Common Object Request Broker Archi ...

  3. ab的压力测试(转)

    其中-n代表请求数,-c代表并发数 返回结果: ##首先是apache的版本信息 This is ApacheBench, Version 2.3 <Revision:655654> Co ...

  4. 吴裕雄--天生自然TensorFlow2教程:全连接层

    out = f(X@W + b) out = relut(X@W + b) import tensorflow as tf x = tf.random.normal([4, 784]) net = t ...

  5. C 语言入门---第十一章---C语言重要知识点补充

    ====C语言typedef 的用法==== 1. C语言允许为一个数据类型起一个新的别名,就像给人起绰号一样. typedef OldName newName; typedef 和 #define ...

  6. 三种方式安装mariadb-10.3.18

    安装环境:CentOS Linux release 7.5.1804 (Core) 一.yum安装 官方网站yum配置方法链接:https://mariadb.com/kb/en/library/yu ...

  7. Web - 实用组件

    1, vue-awesome-swiper  基于 Swiper4.适用于 Vue 的轮播组件,支持服务端渲染和单页应用. 2,  http://www.spritecow.com/     雪碧图背 ...

  8. SAVE 、BGSAVE和BGREWRITEAOF执行区别

    rdbSave 会将数据库数据保存到 RDB 文件,并在保存完成之前阻塞调用者. save 命令直接调用 rdbSave ,阻塞 Redis 主进程:bgsave 用子进程调用 rdbSave ,主进 ...

  9. redis 之redis发布订阅

    Redis 通过 PUBLISH . SUBSCRIBE 等命令实现了订阅与发布模式. 一个Publisher,多个Subscriber模型 如下图所示,可以作为消息队列或者消息通道 主要应用: 一个 ...

  10. 【快学springboot】在springboot中写单元测试

    前言 很多公司都有写单元测试的硬性要求,在提交代码的时候,如果单测通不过或者说单元测试各种覆盖率不达标,会被拒绝合并代码.写单元测试,也是保证代码质量的一种方式. junit单元测试 相信绝大多数的J ...