HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Repetition (Loops) > problem:


018. 50787 - Expected Value

Guest
• Review clarifications (1)

Volume problems

• 012. 50352 - Selling Cows
• 012. 50589 - The Number of Eggs Sold
• 015. 50466 - Drawing Square From...
• 016. 50463 - Drawing a Triangle
• 017. 50423 - Numbers square
• 017. 50537 - esreveR Triangle
• 018. 50344 - Profit or Loss
• 018. 50491 - Brokers
• 018. 50787 - Expected Value
• 019. 50438 - Pattern with stars
• 020. 50485 - Center of gravity of a ...
• 020. 50408 - Molecules
• 022. 50366 - Student Averages (2 G...
• 023. 50437 - Age Labeling
• 024. 50372 - Number Quadruplets
• 025- 2013-Nov-01. 50328 - How far ...
• 026. 50399 - Mobile Base Station

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

Expected Value

You are to open shop and you cannot decide either to open a candy shop or to open a lemonade stand. If you open a candy shop you would probably get $100. And, if you open a lemonade stand, you would probably get $90. In this case you would choose to open a candy shop, because you would earn more money.

But what happens if there is 50% of success when a candy shop is opened. And, if you succeed you would probably get $100, and if you fail, you would probably lose $30.Similarly for the lemonade stand, if there is 50% of success when it is opened. If it's a success you would probably earn $90, and if it's a failure you would probably lose $10.

In such cases, you can calculate the expected values of the projects with the following:

Expected Value =(Probability of Success)*(the amount you win) - (Probability of Failure)*(the amount you lose)

Then for the candy shop,
  Expected Value =(50%)*($100) - (50%)*($30) = $35
And for the lemonade stand,
  Expected Value =(50%)*($90) - (50%)*($10) = $40
The expected value of lemonade stand is $40. Then, you would most probably choose the lemonade stand.

Question: Write a program that is going to get information for n projects and calculate and show the most profitable project for you.

Input specification
You will be given an integer in the beginning: the number of projects (n). you will be given three integers:

  1. Project success percentage: an integer between 0 and 100
  2. The amount you win in case of success: an integer between 0 and 10,000
  3. The amount you lose in case of failure: an integer between 0 and 10,000

Output specification
Show two information

  1. the highest expected value (with two digits precision)
  2. the id of that project.
Note: If there are several projects with the same expected values, show the ID of the first one.

Sample Input I
5
89 30 65
77 64 46
28 48 38
68 50 31
39 17 30
Sample Output I
38.70 2

Explanation:
There are 5 projects given If you start project,

  1. Project #1, you would probably get $19.55
  2. Project #2, you would probably get $38.70
  3. Project #3, you would probably lose $13.92
  4. Project #4, you would probably get $24.08
  5. Project #5, you would probably lose $11.67
So, the most profitable project is #2 with an expected value of 38.70 (0.77*64 - 0.23*46)


Для отправки решений необходимо выполнить вход.

www.contester.ru