Educational Codeforces Round 71 (Rated for Div. 2) A - There Are Two Types Of Burgers

原文链接:https://www.cnblogs.com/xwl3109377858/p/11404050.html

Educational Codeforces Round 71 (Rated for Div. 2)

A - There Are Two Types Of Burgers

There are two types of burgers in your restaurant — hamburgers and chicken burgers! To assemble a hamburger you need two buns and a beef patty. To assemble a chicken burger you need two buns and a chicken cutlet.

You have b buns, p beef patties and f chicken cutlets in your restaurant. You can sell one hamburger for h dollars and one chicken burger for c dollars. Calculate the maximum profit you can achieve.

You have to answer t independent queries.

Input

The first line contains one integer t (1≤t≤100) – the number of queries.

The first line of each query contains three integers b, p and f (1≤b, p, f≤100) — the number of buns, beef patties and chicken cutlets in your restaurant.

The second line of each query contains two integers h and c (1≤h, c≤100) — the hamburger and chicken burger prices in your restaurant.

Output

For each query print one integer — the maximum profit you can achieve.

Example

input

3

15 2 3

5 10

7 5 2

10 12

1 100 100

100 100

output

40

34

0

Note

In first query you have to sell two hamburgers and three chicken burgers. Your income is 2⋅5+3⋅10=40.

In second query you have to ell one hamburgers and two chicken burgers. Your income is 1⋅10+2⋅12=34.

In third query you can not create any type of burgers because because you have only one bun. So your income is zero.

题意:题目意思是给你若干个面包,牛肉,鸡排。两个面包和一个牛肉可以做成一个牛肉面包,

两个面包和一个鸡排可以做成一个鸡肉面包,两种面包有两个价值,问你最大利益。

思路:因为两种面包原料两个面包一样,我们只需要看肉的不同,哪种面包的价值更大,

优先做哪种面包,原料有多可以再做另一种面包,就可以达到最大利益,具体看代码。

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cmath>
 4 #include<cstring>
 5 #include<algorithm>
 6 #include<map>
 7 #include<set>
 8 #include<vector>
 9 #include<queue>
10 #include<stack>
11 #include<list>
12 using namespace std;
13 #define ll long long
14 const int mod=998244353;
15 const long long int inf=1e18+7;
16 //const int maxn=
17
18 int main()
19 {
20     ios::sync_with_stdio(false);
21     int T;
22     cin>>T;
23     int a,b,c;//a个面包,b个牛肉,c个鸡排
24     int x,y;//牛肉面包价格x,鸡肉面包价格y
25     while(T--)
26     {
27         cin>>a>>b>>c>>x>>y;
28         ll int sum=0;
29         if(x>=y)//做牛肉面包划算
30         {
31             sum+=min(a/2,b)*x;
32             a-=min(a/2,b)*2;
33
34             if(a>0)//剩下的做鸡肉面包
35                 sum+=min(a/2,c)*y;
36         }
37         else//做鸡肉面包划算
38         {
39             sum+=min(a/2,c)*y;
40             a-=min(a/2,c)*2;
41
42             if(a>0)//剩下的做牛肉面包
43                 sum+=min(a/2,b)*x;
44         }
45         cout<<sum<<endl;
46     }
47
48     return 0;
49 }

原文地址:https://www.cnblogs.com/xwl3109377858/p/11404050.html

时间: 2024-10-15 19:54:09

Educational Codeforces Round 71 (Rated for Div. 2) A - There Are Two Types Of Burgers的相关文章

Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations

原文链接:https://www.cnblogs.com/xwl3109377858/p/11405773.html Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations You are given a sequence of n pairs of integers: (a1,b1),(a2,b2),…,(an,bn). This sequence is called bad if it is

双元素非递增(容斥)--Number Of Permutations Educational Codeforces Round 71 (Rated for Div. 2)

题意:https://codeforc.es/contest/1207/problem/D n个元素,每个元素有a.b两个属性,问你n个元素的a序列和b序列有多少种排序方法使他们不同时非递减(不同时good). 思路: 真难则反+容斥,反向考虑,ans1=如果a序列非递减则有a中各个数字出现次数的阶乘的乘积个,ans2=b序列也是一样. ans3=然后还要减去a序列和b序列都是good的方案数,就是元素相同的出现次数阶乘的乘积(注意,如果不存在双good就不算ans3). ANS就是:全排列 -

E. XOR Guessing 交互题 Educational Codeforces Round 71 (Rated for Div. 2)

E. XOR Guessing 交互题. 因为这个数最多只有14位 0~13,所以我们可以先处理后面7位,然后再处理后面7位. 因为异或的性质,如果一个数和0异或,那么就等于本身. 所以我们第一次异或1~100 所以 后面从7到13位就都是0,所以结果的后面的7位就可以算出来. 然后同理可以把前面七位找到. #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm>

Educational Codeforces Round 71 (Rated for Div. 2)

A. There Are Two Types Of Burgers 水题.题意:给你面包片数,两种不同的肉饼数(制作一个汉堡要消耗两片面包和一片肉饼),之后再给你两种不同的汉堡售价,问你如何取得最大收益. 思路:照题意模拟即可 ,简单贪心. #include <iostream> #include <sstream> #include <cstring> #include <string> #include <cstdio> #include &

Educational Codeforces Round 36 (Rated for Div. 2)

Educational Codeforces Round 36 (Rated for Div. 2) F. Imbalance Value of a Tree You are given a tree T consisting of n vertices. A number is written on each vertex; the number written on vertex i is ai. Let's denote the function I(x,?y) as the differ

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars There are n pillars aligned in a row and numbered from 1 to n. Initially each pillar contains exactly one disk. The i-th pillar contains a disk having radius ai. You can move these disks

Educational Codeforces Round 36 (Rated for Div. 2) 题解

Educational Codeforces Round 36 (Rated for Div. 2) 题目的质量很不错(不看题解做不出来,笑 Codeforces 920C 题意 给定一个\(1\)到\(n\)组成的数组,只可以交换某些相邻的位置,问是否可以将数组调整为升序的 解题思路 首先如果每个数都能通过交换到它应该到的位置,那么就可以调整为升序的. 但实际上交换是对称的,如果应该在的位置在当前位置前方的数都交换完成,那么整体就是排好序的,因为不可能所有不在相应位置的数都在相应位置的后方.

Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes

Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://codeforces.com/contest/985/problem/E Description Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome w

Educational Codeforces Round 55 (Rated for Div. 2)

Educational Codeforces Round 55 (Rated for Div. 2) 链接 A Vasya and Book 傻逼题..注意判边界. #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #include<set> #include<map> #include<vector> #include<cm