Four Dice
InterviewTime limit1sMemory limit128 MB
Given N sets of four dice rolls, compute each participant's prize by rules based on matching-face patterns and output the maximum prize.
- Level
Easy3 of 10
- Topics
- Implementation, Hash map, Simulation
- Solved
- No attempts yet
Problem
Each participant rolls four dice whose faces are numbered from 1 through 6. The prize for one participant is determined by the combination of the four rolled faces.
- If all four faces are the same, the prize is
50000 + face * 5000. - If exactly three faces are the same, the prize is
10000 + face * 1000. - If there are two different pairs, the prize is
2000 + (sum of the paired faces) * 500. - If there is exactly one pair, the prize is
1000 + paired face * 100. - If all four faces are different, the prize is
largest face * 100.
Given the results for N participants, print the largest prize.
Input
The first line contains the number of participants N. (1 <= N <= 1000)
Each of the next N lines contains four integers separated by spaces, representing the faces rolled by one participant. Each face is an integer from 1 to 6.
Output
Print the largest prize among all participants.