Java Certification
Time limit1sMemory limit128 MB
Given rounded per-category percentages and totals, find n_i and w_i values reproducing them while minimizing the spread between the largest and smallest category size.
- Level
Medium6 of 10
- Topics
- Brute force, Math, Combinatorics
- Solved
- No attempts yet
Problem
You have just finished a Java certification exam with questions. Afterwards you receive a score card summarizing your performance. For example, if you answered 78 of 87 questions correctly, the card might look like this:
The questions are split into categories (here ). Category contains questions with and . You answered questions correctly (here , ), so the total number of wrong answers is (here ).
Let (with ) be the number of wrong answers in category , so that . For each category the card shows the percentage of correct answers, namely rounded to the nearest integer; a value whose fractional part is exactly is rounded to the nearest even integer.
The values and are not necessarily determined uniquely by the card. Assuming the questions are distributed among the categories as evenly as possible, we only consider valid assignments of and that minimize the difference between the largest and the smallest .
Input
The first line contains three integers , , and : the number of correct answers (), the total number of questions (), and the number of categories (). Each of the next lines contains a single integer between and inclusive — the rounded percentage of correct answers in that category. The input always corresponds to at least one valid assignment of and .
Output
A valid assignment of and is not always unique, so output the quantity that is uniquely determined: a single integer — the minimum possible value of , over all assignments of integers and satisfying , , , , and reproducing the given rounded percentage for every category.