#P9380. Minimum Total Votes
Minimum Total Votes
Minimum Total Votes
Before server shutdown, the operations team held a series of votes to investigate which game content impressed players the most. As one of the loyal players of the series, you are curious about how many people participated in the vote. However, only the final rounded vote percentages are published. For a vote with \( N \) options, the published percentage for option \( i \) is \( P_i \) (\( 1\le i\le N \)). The percentages \( P_i \) have been rounded to \( L \) decimal places using standard rounding (i.e. round half up).
Assume the real number of votes is \( K \), and for each option \( i \), \( D_i \) players voted for that option so that \( K=\sum_{i=1}^{N}D_i \) with each \( D_i \) being a nonnegative integer. The original percentage for option \( i \) is \( \frac{D_i}{K} \) and it satisfies the rounding condition in the following inequality: \[ P_i - \frac{1}{2}\times10^{-L} \le \frac{D_i}{K} < P_i + \frac{1}{2}\times10^{-L} \] Determine the minimum positive integer \( K \) such that there exist nonnegative integers \( D_i \) meeting the above conditions for all \( i \).
inputFormat
The first line contains two integers \( N \) and \( L \) \( (1 \le N \le 10,\, 1 \le L \le 6) \) separated by a space.
The second line contains \( N \) floating-point numbers \( P_1, P_2, \dots, P_N \) (each having exactly \( L \) digits after the decimal point) representing the rounded percentages. It is guaranteed that \( \sum_{i=1}^{N} P_i = 1.0 \).
outputFormat
Output a single integer, the minimum total number of votes \( K \) that can produce the given rounded percentages.
sample
2 1
0.5 0.5
2