Back
Close

Bet payout calculator

Statement

 Goal

You are the administrator of an online casino system. You want to cheat your customers by manipulating the results of their dice rolls!
You must write a script to calculate which result would allow you to keep the maximum amount of money in every game, here are the rules:

Every game is based on a dice-roll, the sides of the dice involved are dynamic and might change from game to game.

You will receive details for every side of the dice, including the face_number, the win_multiplier (a value that determines the payout of the bet in case the dice falls on that number) and the amount of money placed on it, for example:

Consider this setup
dice_sides: 2
face_number: 1, win_multiplier: 2, money: 750
face_number: 2, win_multiplier: 2, money: 940

In this case:
If you make the die fall on the face numbered "1" you will keep 940$, but you will have to pay out 750*2 = 1500$, leaving you with -560$;
If you make the die fall on the face numbered "2" you will keep 750$, but you will have to pay out 940*2 = 1880$, leaving you with -1130$;
so the optimal output would be:
1 -560.00

The output value must have 2 decimal places,
if it has more, it must be rounded,
if it has less, you must append '0' until it has 2.

If there are multiple results that yield the best gain, output the first one in the list.
Input
Line 1: An integer N representing number of sides of the dice.
Next N lines: Three space separated numbers face_number (an integer), win_multiplier and money (floats) representing the number displayed on the side, the payout multiplier, and the bets currently on the number.
Output
Line 1: The optimal face number to win and the money you would keep (rounded to 2 decimals)
Constraints
2 ≤ N ≤ 100
1 < multiplier < 10
0 < money < 10000
Example
Input
2
1 2 750
2 2 940
Output
1 -560.00

Tags
MathematicsConditionsOutput formatting

Difficulty
Easy

Test cases
Simple Test Test
Input
2 1 2 750 2 2 940
Output
1 -560.00

Simple Validator Validator
Input
3 1 3 150 2 2 240 3 1 730
Output
1 520.00

Tie-breaker Test
Input
4 1 5.95 6258 2 5.22 1662.50 3 4.45 2157 4 5.22 1662.50
Output
2 1399.25

Tie-breaker Validator Validator
Input
6 1 6.61 4233.52 2 3.82 555.74 3 2.62 6252.92 4 3.82 555.74 5 8.04 1075.29 6 3.82 555.74
Output
2 10550.28

Scrambled sides Test
Input
5 4 6.03 3682 3 8 7516.83 2 4.75 1903.12 1 3.87 3895.21 5 2.82 1587.81
Output
5 12519.54

Scrambled sides validator Validator
Input
4 1 6.13 9458.55 4 8.68 4892.57 3 5.33 5812 2 7.23 1260.19
Output
2 11051.95

Many faces Test
Input
9 1 4.258 5255.44 2 2.369 4040.91 3 6.42 4261.12 4 8.17480 8553.29 5 5.94 557.40 6 3.08 9782.49 7 3.2916 1891.87 8 2.22 4386.39 9 7.1144 1317.20
Output
5 36177.75

Many faces validator Validator
Input
9 1 1.258 5255.44 2 1.344 5100.91 3 1.122 5322.12 4 1.15 5123.29 5 1.07 5187.40 6 1.287 5264.49 7 1.288 5322.87 8 1.512 5644.39 9 1.116 5532.20
Output
5 37015.19

Lots of decimal values Test
Input
7 1 1.5265489 7654.26 2 2.484891 8500.18 3 4.2194948 984.46 4 6.1818025 4922.25 5 1.484648 7846.46 6 3.414845 484.14 7 9.5494847 6876.49
Output
6 35130.84

Lots of decimal values validator Validator
Input
9 1 4.548089 8825.91 2 2.78227 7270.77 3 6.4492796 6919.19 4 3.65739608 2587.41 5 6.865 9565.46 6 6.42212 6705.34 7 7.37637 7998.74 8 6.503385 6016.02 9 7.429876 1392.24
Output
9 45544.67

Tons of faces Test
Input
90 1 5.74 4772.70 2 7.34 1960.55 3 3.43 8197.78 4 8.58 7938.35 5 4.17 1684.26 6 8.87 9897.49 7 2.43 7803.93 8 9.70 5525.51 9 2.82 8936.13 10 9.34 8008.43 11 3.61 1458.32 12 3.91 5442.67 13 2.24 8257.32 14 7.09 2040.62 15 8.88 3750.35 16 5.11 1221.28 17 5.90 1172.95 18 4.96 6828.08 19 8.15 3838.46 20 9.87 3307.32 21 7.44 6061.31 22 4.22 1891.09 23 8.93 7183.04 24 7.43 4547.95 25 4.52 4884.18 26 6.11 1724.10 27 3.68 6718.82 28 4.19 728.90 29 9.04 3875.53 30 9.01 349.08 31 2.20 5895.30 32 3.46 9523.15 33 6.79 6766.69 34 2.12 1194.06 35 8.95 8291.39 36 2.63 9353.08 37 8.11 5967.81 38 5.31 7973.38 39 6.32 7735.81 40 4.24 9624.94 41 5.46 3950.79 42 6.36 942.72 43 6.58 8230.01 44 8.49 5139.85 45 7.39 5640.03 46 6.17 5062.12 47 9.35 482.37 48 7.68 3756.96 49 9.45 2037.26 50 2.96 4556.00 51 8.17 683.66 52 4.42 8237.06 53 8.06 3405.25 54 4.28 7245.72 55 4.27 3956.26 56 6.68 6464.19 57 8.82 5275.04 58 4.30 6332.44 59 8.66 40.27 60 4.06 2703.76 61 9.13 9273.37 62 8.96 7066.50 63 3.89 4191.44 64 9.08 4460.87 65 9.22 8582.36 66 8.19 7541.49 67 9.27 6375.64 68 6.77 3656.64 69 5.62 9604.96 70 7.73 3367.38 71 4.68 200.57 72 5.79 2859.66 73 4.34 1703.44 74 8.71 4002.65 75 7.41 8410.35 76 8.37 8824.27 77 6.06 1800.71 78 5.73 2433.95 79 9.00 1296.41 80 4.55 6909.19 81 8.13 9681.18 82 5.20 6779.94 83 7.74 2832.30 84 6.32 6923.68 85 3.20 9432.33 86 8.90 9372.71 87 9.19 1694.45 88 3.25 8181.07 89 4.36 8055.97 90 5.58 5614.35
Output
59 467214.69

Tons of faces validator Validator
Input
90 1 9.52 1455.45 2 5.48 6260.98 3 7.20 2139.85 4 6.22 8840.53 5 2.67 8919.29 6 8.59 6764.19 7 3.59 3486.33 8 5.93 4786.71 9 3.17 9157.87 10 5.01 9211.71 11 8.02 2369.27 12 8.14 8899.52 13 4.52 8623.17 14 8.72 9893.71 15 3.60 106.50 16 9.69 7481.73 17 5.61 9938.99 18 6.11 5749.15 19 3.64 4184.87 20 8.88 9647.79 21 9.47 5393.56 22 7.70 8068.98 23 6.69 729.63 24 2.43 5260.13 25 2.01 6194.38 26 9.12 9416.06 27 5.60 2715.48 28 8.03 3686.08 29 3.30 2064.66 30 7.31 4759.37 31 7.16 1623.29 32 3.47 2614.01 33 8.42 7419.88 34 7.89 7050.14 35 4.04 2091.77 36 8.29 9206.33 37 9.00 8523.53 38 3.73 6362.27 39 3.46 4437.05 40 7.61 290.38 41 7.11 1842.90 42 6.32 1741.07 43 9.93 6530.69 44 6.86 8053.83 45 3.35 6506.32 46 3.05 4115.87 47 6.55 3704.27 48 8.33 7105.97 49 4.31 8939.80 50 4.60 3049.57 51 5.74 7858.38 52 4.94 2047.33 53 5.33 4748.38 54 9.41 863.66 55 8.93 4482.51 56 5.22 1559.87 57 8.40 92.88 58 3.95 6573.46 59 5.75 8390.28 60 8.42 4831.05 61 7.16 626.16 62 7.57 280.42 63 2.87 5870.59 64 6.08 7540.11 65 4.06 9852.17 66 5.33 1443.41 67 9.08 4664.93 68 4.30 1519.95 69 5.43 6570.62 70 9.53 4457.26 71 3.08 9902.08 72 6.32 2456.32 73 9.57 5862.86 74 6.14 5665.77 75 4.03 3827.67 76 4.15 3735.24 77 2.22 4550.37 78 3.14 1596.06 79 9.18 1363.21 80 5.99 2899.29 81 4.66 9107.56 82 6.82 7883.29 83 6.05 2.71 84 7.15 3699.61 85 6.42 2262.65 86 4.82 1118.47 87 9.95 2927.94 88 6.28 9858.87 89 8.10 987.53 90 4.86 6681.72
Output
83 448058.41

Solution language

Solution

Stub generator input