#arc174b. B - Bought Review
B - Bought Review
Score: points
问题陈述
为 个测试案例解决以下问题。
在美食评论网站 EatCocoder 上,您可以用从 到 的整数星级来评价餐厅。 最初,由厨师 B 管理的餐厅有 条 星级的评论。 厨师可以向 EatCocoder 管理层支付 日元的贿赂,以获得额外的一条 星级评论。
通过贿赂总共增加 条评论后,将总共有 条评论。 厨师 B 希望这些评论的平均评分至少为 3 星级。确定实现此目的所需的最少贿赂总额。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
Solve the following problem for test cases.
On the gourmet review site EatCocoder, you can review restaurants with an integer number of stars from to .
Initially, the restaurant managed by Chef B has reviews with stars.
The chef can pay a bribe of yen to the EatCocoder administration to have one additional -star review.
After adding a total of reviews by bribery, there will be reviews in total.
Chef B wants the average rating of these reviews to be at least stars. Determine the minimum total amount of bribery required to achieve this.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Here, represents the -th test case.
Each test case is given in the following format:
Output
Print lines in total.
The -th line should contain the answer to the -th test case as an integer.
Sample Input 1
6
1 0 1 0 0
1 2 3 4 5
0 2 2 0 0
1 1 1 1 5
0 1 2 0 0
1 1 1 5 3
1 1 1 0 0
1 1 1 1 1
0 0 0 0 1
1 1 1 1 1
100000000 100000000 100000000 0 0
100000000 100000000 100000000 100000000 100000000
Sample Output 1
5
2
3
2
0
15000000000000000
This input contains six test cases.
- For the first test case, you can, for example, do the following to have an average rating of at least stars with a bribe of yen, which is the minimum possible amount.
- Initially, there are reviews with stars, respectively.
- Pay a bribe of yen to add one -star review.
- As a result, there are reviews with stars, respectively, averaging stars.
- For the second test case, you can, for example, do the following to have an average rating of at least stars with a bribe of yen, which is the minimum possible amount.
- Initially, there are reviews with stars, respectively.
- Pay a bribe of yen to add two -star reviews.
- As a result, there are reviews of with stars, respectively, averaging stars.
- For the third test case, you can, for example, do the following to have an average rating of at least stars with a bribe of yen, which is the minimum possible amount.
- Initially, there are reviews with stars, respectively.
- Pay a bribe of yen to add one -star review.
- As a result, there are reviews with stars, respectively, averaging stars.
- For the fourth test case, you can, for example, do the following to have an average rating of at least stars with a bribe of yen, which is the minimum possible amount.
- Initially, there are reviews with stars, respectively.
- Pay a bribe of yen to add one -star review.
- Pay a bribe of yen to add one -star review.
- As a result, there are reviews with stars, respectively, averaging stars.
- For the fifth test case, you can, for example, do the following to have an average rating of at least stars with a bribe of yen, which is the minimum possible amount.
- Initially, there are reviews with stars, respectively.
- Since the average is already , which is not less than , give no bribe.
- For the sixth test case, note that the answer may not fit into a -bit signed integer.