codeforces-1271A - Suits
A new delivery of clothing has arrived today to the clothing store. This delivery consists of aa ties, bb scarves, cc vests and dd 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 ee coins, and each suit of the second type costs ff 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).
The first line contains one integer aa (1≤a≤100000) — the number of ties.
The second line contains one integer bb (1≤b≤100000) — the number of scarves.
The third line contains one integer cc (1≤c≤100000) — the number of vests.
The fourth line contains one integer dd (1≤d≤100000) — the number of jackets.
The fifth line contains one integer ee (1≤e≤1000)— the cost of one suit of the first type.
The sixth line contains one integer ff (1≤f≤1000) — the cost of one suit of the second type.
Print one integer — the maximum total cost of some set of suits that can be composed from the delivered items.
4
5
6
3
1
2
6
12
11
13
20
4
6
102
17
14
5
21
15
17
325
It is possible to compose three suits of the second type in the first example, and their total cost will be 66 . Since all jackets will be used, it's impossible to add anything to this set.
The best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9⋅4+11⋅6=102.
题目大意:在一个服装店中有领带a个,围巾b个,背心c个,夹克d个。
现在有两种搭配:
1.a+d e元
2.b+c+d f元
最佳搭配方案使得钱数最大
思路:比较e,f分类讨论
AC代码:
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
inline int read() {int x=,f=;char c=getchar();while(c!='-'&&(c<''||c>''))c=getchar();if(c=='-')f=-,c=getchar();while(c>=''&&c<='')x=x*+c-'',c=getchar();return f*x;}
typedef long long ll;
const int maxn = 1e6+;
int main()
{
ll a,b,c,d,e,f;
cin>>a>>b>>c>>d>>e>>f;
if(e>=f){
if(a>=d){
printf("%lld\n",e*d);
}
else{
ll sum=e*a;
d-=a;
ll t=min(b,min(c,d));
sum+=f*t;
printf("%lld",sum);
}
}
else{
ll t=min(b,min(c,d));//求三数最小值
ll sum=t*f;
d-=t;
if(d>){
int y=min(a,d);
sum+=e*y;
}
printf("%lld",sum);
}
return ;
}
codeforces-1271A - Suits的更多相关文章
- [Codeforces #608 div2]1271A Suits
Description A new delivery of clothing has arrived today to the clothing store. This delivery consis ...
- Codeforces Round #608 (Div. 2) 题解
目录 Codeforces Round #608 (Div. 2) 题解 前言 A. Suits 题意 做法 程序 B. Blocks 题意 做法 程序 C. Shawarma Tent 题意 做法 ...
- 【codeforces 760C】Pavel and barbecue
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【cf补题记录】Codeforces Round #608 (Div. 2)
比赛传送门 再次改下写博客的格式,以锻炼自己码字能力 A. Suits 题意:有四种材料,第一套西装需要 \(a\).\(d\) 各一件,卖 \(e\) 块:第二套西装需要 \(b\).\(c\).\ ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
随机推荐
- 解决pycharm创建github工程但push失败的问题
1.运行git-cmd.exe; 2.d: cd 工程路径 3.执行命令:git remote set-url origin https://github.com/wawj901124/jmet ...
- (转)数据库分片Shard操作
2.1.1什么是数据切分 "Shard" 这个词英文的意思是"碎片",而作为数据库相关的技术用语,似乎最早见于大型多人在线角色扮演游戏中."Shard ...
- php基础系列之 数据的存储和读取
·文件处理 ·写入一个文件 1,打开这个文件.如果这个文件不存在,需要先创建它 2,将数据写入这个文件 3,关闭这个文件 ·从一个文件读出数据 1,打开这个文件.如果这个文件不能打开(例如,文件不存在 ...
- Mybatis面试问题集锦
1.#{}和${}的区别是什么? 答:mybatis在处理#{}时,会将sql中的#{}替换为?号,调用PreparedStatement的set方法来赋值: mybatis在处理 $ { } 时,就 ...
- OpenCV图像载入、显示和输出到文件以及滑块的使用
图像载入 imread()函数 Mat imread(const string& filename, int flags = 1); 第一个参数为文件名 第二个参数为载入标识 flags &g ...
- 洛谷P1327 数列排序
https://www.luogu.org/problem/P1327 #include<bits/stdc++.h> #define Ll long long using namespa ...
- linux软件下载
可以到linux官网下载:http://vault.centos.org/6.10/os/Source/SPackages/
- 每天进步一点点------Allegro 群组布线
执行Route->connect命令,设置好控制面板中的内容.然后设置同时走线的GROUP包含哪些网络,有两种方法.第一种方法,如果几个网络是紧邻的,可以直接框选,选中的网络就会被包含在GROU ...
- hdu1874 (spfa 最短路)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1874 很简单的最短路问题,刚刚学习spfa,其实很简单,思想和一维动态规划差不多,数组d[i]表示起点 ...
- Redis04——Redis五大数据类型 key
key keys * 查看当前库的所有键 exists <key> 判断某个键是否存在 type <key> 查看键的类型 del<key> 删除 ...