BOJ - 14718 - 용감한 용사 진수

Updated:

import sys

def solution():
    ma = 1e9
    mb = 1e9
    mc = 1e9
    ans = 1e9

    N, K = map(int, sys.stdin.readline().split())

    soldier = []
    for _ in range(N):
        soldier.append(list(map(int, sys.stdin.readline().split())))

    cnt = 0
    for i in range(N):
        for j in range(N):
            for k in range(N):
                cnt = 0
                a = soldier[i][0]
                b = soldier[j][1]
                c = soldier[k][2]

                for l in range(N):
                    if a >= soldier[l][0] and b >= soldier[l][1] and c >= soldier[l][2]:
                        cnt += 1
                    if cnt >= K and ans >= cnt and a + b + c < ma + mb + mc:
                        ans = cnt
                        ma = a
                        mb = b
                        mc = c

    print(ma + mb + mc)


solution()

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

Categories:

Updated:

Leave a comment