2309번 – 일곱난쟁이

2

문제

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

풀이

코드

def answer(arr):
  _sum = sum(arr)
  ans = []
  for i in range(len(arr)-1):
    for j in range((i+1), len(arr)):
      if _sum - (arr[i]+arr[j]) == 100:
        for k in range(len(arr)):
          if k not in [i,j]: ans.append(arr[k])
        ans = sorted(ans)
        for i in range(len(ans)): print(ans[i])
        return
arr = []
for _ in range(9): arr.append(int(input()))
answer(arr)

Add Comment