There Are Two Types Of Burgers (Educational Codeforces Round 71)

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.

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;
#define pq priority_queue<int>
#define pql priority_queue<ll>
#define pqn priority_queue<node>
#define v vector<int>
#define vl vector<ll>
#define lson rt<<1, l, m  
#define rson rt<<1|1, m+1, r
#define read(x) scanf("%d",&x)
#define lread(x) scanf("%lld",&x);
#define pt(x) printf("%d\n",(x))
#define yes printf("YES\n");
#define no printf("NO\n");
#define gcd __gcd
#define cn cin>>
#define ct cout<<
#define ed <<endl;
#define ok return 0 ;
#define over cout<<endl;
#define rep(j,k) for (int i = (int)(j); i <= (int)(k); i++)
#define input(k) for (int i = 1; i <= (int)(k); i++)  {cin>>a[i] ; }
#define mem(s,t) memset(s,t,sizeof(s))
#define re return 0;
#define TLE std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod(x) ((x)%9973)
#define test cout<<"     ++++++      "<<endl; 
typedef long long ll;
const int N=150000+5;
const int maxn=10000+5;
const int len = 2*1e5+5;
typedef struct node
{
    int x,y,ankle,T;
}node;
node dp[len]; 
int a[N];
double getlen(node xx,node yy) { return ( (xx.x-yy.x)*(xx.x-yy.x) +(xx.y-yy.y)*(xx.y-yy.y) ); } //计算两点间距离 
int main()
{
    int t,m,n,k,l,r;
    for(cin>>t;t;t--)
    {
        cin>>n>>m>>k>>l>>r;
        n/=2;
        if(l>r)
        {
            if(n>m) cout<<m*l+min(n-m,k)*r<<endl;
            else cout<<n*l<<endl;
        }
        else if(r>l)
        {
            if(n>k) cout<<k*r+min(n-k,m)*l<<endl;
            else cout<<n*r<<endl;
        }
        else
        {
            cout<<min(m+k,n)*l<<endl;
        }

    }
    ok;
} 

 

上一篇:模板字符串


下一篇:Set Operation / OpenJ_Bailian - 2443