Dice Game

Tristan·2024년 6월 30일

There is a game in which three dice with eyes from 1 to 6 are thrown to receive the prize money according to the following rules.

Rule (1) If you get three identical eyes, you will receive a prize of 10,000 KRW + (same eyes)1,000. Rule (2) If only two identical eyes come out, you will receive a prize of 1,000 KRW + (same eyes)100 KRW. Rule (3) If both eyes come out differently, you will receive a prize of 100 KRW.

For example, if you are given three eyes 3, 3, and 6, the prize money will be calculated as 1,000+3100, and you will receive 1,300 KRW. If the three eyes are given as 2, 2, and 2, it will be calculated as 10,000+21,000 and you will receive 12,000 KRW. If the three eyes are given as 6, 2, and 5, the largest value of them is 6, so it will be calculated as 6*100, and you will receive 600 KRW as a prize money.

Input:

The first line is given the number of participants N (2<=N<=1,000) and from the next line on N lines, each of the three eyes that people threw dice with the blank spaces between them.

Output:

In the first line, the prize money of the person who receives the most prize money is printed.

Input Example:

3
3 3 6
2 2 2
6 2 5

Output Example:

12000

Solution

  • we first need for loop that will repeat until the n
  • in the for loop, create a value that will accept the each number of the dice
  • we will sort the dice and create a,b,c that will accept the numbers of dice
  • create a first if loop that will apply the rule 1 (three same numbers)
  • create an elif loop that will apply the rule 2 (two same numbers, a ==b and a ==c)
  • now make sure we create an another elif loop that will meet the condition of (b==c) this is b/c we have not considered b==c in the first elif loop
  • end with the rule 3 with else loop
  • since we need to submit the largest number, make sure to save the largest number in the res
n = int(input())
res = 0

for i in range (n):
    li = input().split()
    li.sort()
    a,b,c = map(int, li)
    
    if a == b and b == c:
        m = 10000 + (a) * 1000
    
    elif a == b or a == c:
        m = 1000 + (a) * 100
    
    elif b == c:
        m = 1000 + (b) * 100
    
    else:
        m = c * 100
    
    if m > res:
        res = m
        
print (res)
profile
@Columbia

0개의 댓글