BOJ - 2863 - 섬의 개수

Updated:

import sys

def solution():    
    A, B = map(int, input().split(' '))
    C, D = map(int, input().split(' '))

    number = [A, B, C, D]
    index = [
        [0, 1, 2, 3],
        [2, 0, 3, 1],
        [3, 2, 1, 0],
        [1, 3, 0, 2]
    ]

    ret = [0, -1]

    for i in index:
        result = (number[i[0]] / number[i[2]] + number[i[1]] / number[i[3]])
        if ret[0] < result:
            ret[0] = result
            ret[1] = i

    print(index.index(ret[1]))

solution()

https://www.acmicpc.net/problem/2863

Categories:

Updated:

Leave a comment