7.1 Vaibhav’s Cooking Contest
Score: 20pts
Time Limit: 5.00 sec
Vaibhav is participating in a cooking contest where there are 5 judges evaluating his dish.
Each judge will give a score out of 10.


Vaibhav knows the scores each judge is planning to give in advance: S1, S2, S3, S4, S5.


To win the contest, Vaibhav needs an average score of at least 7.


Vaibhav can convince a judge to give a perfect score (10) by spending 100 coins.
What is the minimum number of coins Vaibhav needs to guarantee that he wins?

Constraints
1≤T≤10^4 — number of test cases.

For each test case, five integers S1,S2,S3,S4,S5

0≤Si≤100 for every i. (scores are integers out of 10)

Output per test case is an integer number of coins (a multiple of 100).

Input Format
The first line contains an integer T, the number of test cases.

Each of the next T lines contains 5 integers: S1 S2 S3 S4 S5 — the planned scores of the judges.

Output Format
Output Format
For each test case, print a single integer — the minimum number of coins Vaibhav must spend.

Example 1
Input:
3
7 7 0 7 7
7 7 7 7 7
0 0 0 0 0

Output:
100
0
400

Explanation:
Test Case 1: The scores are 7,7,0,7,7. By spending 100 coins to convince the judge who gave 0 to give 10 instead, the new scores are 7,7,10,7,7 → average 7.6 → Vaibhav wins.
Test Case 2: The average is already 7 → Vaibhav doesn’t need to spend any coins.
Test Case 3: All judges give 0 → Vaibhav needs to convince all 4 judges to reach average ≥ 7 → 4 × 100 = 400 coins.

Log In to solve the Question