题解:AT_arc174_b [ARC174B] Bought Review
WildBacteriophage · · 题解
题目大意
餐厅有
题目解法
推式子
其实花钱买
那么问题转化成了我们要求满足
的情况下
最小值。
变形:
小分讨
接下来是分类讨论,分为几种情况:\
如果
AC 代码
:::success[Code]
#include <iostream>
#define int long long
using namespace std;
int t, sum, cnt, P4, P5;
signed main() {
cin >> t;
while (t --) {
sum = cnt = 0;
for (int i = 1; i <= 5; i ++) {
int x;
cin >> x;
sum += x * i;
cnt += x;
}
for (int i = 1; i <= 4; i ++) cin >> P4;
cin >> P5;
int temp = 3 * cnt - sum;
if (temp <= 0) {
cout << 0 << '\n';
continue;
}
if (2 * P4 <= P5) {
cout << temp * P4 << '\n';
} else {
if (temp % 2 == 0) cout << temp / 2 * P5 << '\n';
else {
if (P4 < P5) cout << temp / 2 * P5 + P4 << '\n';
else cout << (temp / 2 + 1) * P5 << '\n';
}
}
}
return 0;
}
:::