๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿƒ algorithm/boj

BOJ 20044 - Project Teams

by HandHand 2021. 3. 8.

๋ฌธ์ œ

๋ฐฑ์ค€ ์˜จ๋ผ์ธ ์ €์ง€ - 20044๋ฒˆ

ํ’€์ด ๊ณผ์ •

๋‘ ๋ช…์”ฉ ํŒ€์›์„ ๊ตฌ์„ฑํ•  ๋•Œ, ํŒ€์›๋“ค์˜ ์ฝ”๋”ฉ ๋Šฅ๋ ฅ์˜ ํ•ฉ๋“ค ์ค‘ ๊ฐ€์žฅ ์ž‘์€ ๊ฒฝ์šฐ๋ฅผ ์ตœ๋Œ€ํ™”ํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค.

๋‘ ๋ช…์”ฉ ๋ฌถ๊ธฐ ๋•Œ๋ฌธ์— ๋Šฅ๋ ฅ์น˜๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌํ•œ ๋‹ค์Œ ์–‘ ๋์— ์žˆ๋Š” ํ•™์ƒ๋“ค๋ผ๋ฆฌ ๋ฌถ์–ด์ฃผ๋ฉด ๋˜๋Š” ๊ทธ๋ฆฌ๋”” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค.

์ฝ”๋“œ


import sys

N = int(input())
stats = list(map(int, sys.stdin.readline().split()))


def solution():
    stats.sort()

    answer = sys.maxsize

    for i in range(N):
        s = stats[i] + stats[2 * N - i - 1]
        answer = min(answer, s)

    return answer


print(solution())
๋ฐ˜์‘ํ˜•

๐Ÿ’ฌ ๋Œ“๊ธ€