Problem Statement
Solve the following problem for $T$ test cases.
On the gourmet review site EatCocoder, you can review restaurants with an integer number of stars from $1$ to $5$.
Initially, the restaurant managed by Chef B has $A_i$ reviews with $i$ stars. $(1 \le i \le 5)$
The chef can pay a bribe of $P_i$ yen to the EatCocoder administration to have one additional $i$-star review. $(1 \le i \le 5)$
After adding a total of $k$ reviews by bribery, there will be $A_1+A_2+A_3+A_4+A_5+k$ reviews in total.
Chef B wants the average rating of these reviews to be at least $3$ stars. Determine the minimum total amount of bribery required to achieve this.
Constraints
- All input values are integers.
$1 \le T \le 10^4$$0 \le A_i \le 10^8$$1 \le A_1+A_2+A_3+A_4+A_5$$1 \le P_i \le 10^8$
Input
The input is given from Standard Input in the following format:
T
\rm{Case}_1
\rm{Case}_2
\vdots
\rm{Case}_T
Here, $\rm{Case}$$_i$ represents the $i$-th test case.
Each test case is given in the following format:
A_1 A_2 A_3 A_4 A_5
P_1 P_2 P_3 P_4 P_5
Output
Print $T$ lines in total.
The $i$-th line should contain the answer to the $i$-th test case as an integer.
样例
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
5
2
3
2
0
15000000000000000
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。