Princess' Gamble
InterviewTime limit8sMemory limit512 MB
Given ticket counts per competitor, a winning competitor, and a deduction percentage, compute the payout per winning ticket, or 0 if no winning tickets exist.
- Level
Easy3 of 10
- Topics
- Math, Implementation, Simulation
- Solved
- No attempts yet
Problem
A tomboyish and brave princess of a poor country once broke down the wall of her room, slipped out of the castle, and walked into a gambling house where bets such as horse racing are placed. The princess, who had never gambled before, lost heavily. Finding this situation unpleasant, she investigated how the gambling was actually run. She discovered that the payouts in this kind of gambling are determined by a method called the pari-mutuel system.
The pari-mutuel system is a calculation method used to determine payouts in gambling on races. In this system, all stakes are pooled, a fixed percentage is deducted, and the remainder is distributed to the winners in proportion to their stakes.
The gambling the princess is currently absorbed in works as follows: before the race, participants buy voting tickets at 100 gold each, predicting which competitor will win, and if the result matches their prediction, they gain the right to receive a payout. Gold is the currency unit of this country. Your job is to write a program that computes the payout per voting ticket from the race information given as input.
If the payout computed by the method above is not an integer, round it down to an integer.
Input
The input consists of multiple data sets. The number of data sets is at most 100. After the last data set, a line consisting of "0 0 0" is given to mark the end of the input.
Each data set has the following format.
N M P
X1
...
XN
In the first line, N is the number of competitors subject to voting, M is the number of the winning competitor, and P is the deduction rate (a percentage) as an integer. Xi is the number of voting tickets cast for the i-th competitor. You may assume 1 ≦ N ≦ 100, 1 ≦ M ≦ N, 0 ≦ P ≦ 100, and 0 ≦ Xi ≦ 1000.
Output
For each data set, output one line consisting of an integer that is the payout amount per winning voting ticket. If nobody won the bet, output 0. The output line must contain no other characters.