#K77377. Maximum Total Payout Simulation
Maximum Total Payout Simulation
Maximum Total Payout Simulation
You are given two slot machines. Each machine has a fixed set of payout values. You will perform N plays. In each play, you must choose a machine to play. The machine that you play is chosen based on the following rule:
- If the average payout of machine1 is greater than the average payout of machine2, choose machine1.
- Otherwise, choose machine2.
Once a machine is chosen, you receive a payout equal to the maximum payout available on that machine. The total payout is computed as:
\[ \text{Total Payout} = N \times \max(\text{chosen machine payouts}) \]
Your task is to compute the maximum possible total payout according to the rule above.
inputFormat
The input is read from stdin and consists of three lines:
- The first line contains a single integer N which represents the number of plays.
- The second line contains space-separated integers representing the payout values of machine1.
- The third line contains space-separated integers representing the payout values of machine2.
outputFormat
Output a single integer to stdout denoting the maximum possible total payout computed as \(N \times \max(\text{chosen machine payouts})\). The chosen machine is determined as follows:
- If \(\frac{\sum machine1}{|machine1|} > \frac{\sum machine2}{|machine2|}\), choose machine1.
- Otherwise, choose machine2.
5
1 -1 2
2 1 -2
10