AcWing 3776. 水果拼盘(if大法)
原题链接
简单
作者:
白墙
,
2021-07-23 10:53:19
,
所有人可见
,
阅读 181
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 1e5 + 10;
typedef pair<int, int> PII;
void solve () {
int a, b, c, d, e, f;
cin >> a >> b >> c >> d >>e >> f;
if (d >= a && d >= b && d >= c) {
if (f > e) {
cout << (min (b, c) * f) + min((d - min(b, c)), a) * e << endl;
}
else {
cout << a * e + min(d - a, min(b, c)) * f << endl;
}
}
else if (d <= a && d <= b && d <= c) {
cout << d * max(e, f) << endl;
}
else {
if (b > c) swap (b, c);
if (d >= a && d <= c) {
if (f > e) {
cout << min (b, d) * f + (d - min (b, d), a) * e << endl;
}
else {
cout << a * e + min((d - a), b) * f << endl;
}
}
else if (d >= a && d <= b) {
if (f > e) {
cout << d * f << endl;
}
else {
cout << a * e + (d - a) * f << endl;
}
}
else if (d >= b && d <= c) {
if (f > e) {
cout << b * f + min(d - b, a) * e << endl;
}
else {
if (d >= a) {
cout << a * e + min(d - a, b) * f << endl;
}
else {
cout << d * e << endl;
}
}
}
else if (d <= a) {
if (f <= e) {
cout << d * e << endl;
}
else {
if (d >= b && b <= c) {
cout << b * f + min(b - d, a) * e << endl;
}
else if (d >= b && d >= c) {
cout << b * f + min(d - b, a) * e <<endl;
}
}
}
}
}
int main () {
int t;
cin >> t;
while (t --) solve();
return 0;
}