#GD0000185. Bảng điểm toàn A (Straight A's)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Bảng điểm toàn A (Straight A's)
Straight A's
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Noora has integer marks in her school register. Every mark lies between and the maximum mark . Her graduation mark is the arithmetic mean of all marks, rounded to the nearest integer, with exact half-integers rounded up. Noora wants to obtain graduation mark . You may append additional integer marks between and , but must append as few as possible. Find that minimum number.
Input
Line 1 contains two integers and : the number of existing marks and the maximum possible mark.
Line 2 contains exactly integers , the existing marks in their register order.
Output
Print one integer: the minimum number of additional marks needed to make the rounded graduation mark equal to .
Subtasks
- Subtask 1 (20 points): ; ; for every .
- Subtask 2 (30 points): ; ; for every .
- Subtask 3 (50 points): ; ; for every .
Examples
Example 1
Input
2 10
8 9
Output
4
Explanation
The current marks are and , totaling . Appending marks of yields an average . To round to , it must reach . With the average is , too low; with it is and rounds up to . The answer is .
Example 2
Input
3 5
4 4 4
Output
3
Explanation
The three existing marks total . Adding three marks of gives total over six marks, average , which rounds up to . Adding only two marks of would give , which is insufficient.