Codeforces Round #608 (Div. 2) A. Suits

链接:

https://codeforces.com/contest/1271/problem/A

题意:

A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d 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 e coins, and each suit of the second type costs f 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).

思路:

判断优先级

代码:

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int a, b, c, d, e, f;
    scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
    if (e > f)
    {
        int ans = e*min(a, d);
        d -= min(a, d);
        ans += f*min(b, min(c, d));
        printf("%d\n", ans);
    }
    else
    {
        int ans = f*min(b, min(c, d));
        d -= min(b, min(c, d));
        ans += e*min(a, d);
        printf("%d\n", ans);
    }

    return 0;
}

猜你喜欢

转载自www.cnblogs.com/YDDDD/p/12089052.html