본문 바로가기
python-algorithm

백준 22993 서든어택 3

by 무적김두칠 2021. 8. 26.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import sys
n=int(sys.stdin.readline())
tmp1=(list(map(int, sys.stdin.readline().split())))
jun=tmp1[0]
tmp1.pop(0)
tmp1.sort()
for i in tmp1:
  if i<jun :
    jun+=i
    ans="Yes"
  else:
    ans="No"
    break
if len (tmp1)!=0print(ans)
elseprint("Yes")
cs

어려운 문제는 아니구요
sort해서 풀면 쉬운데
LIne 14-15는 예외처리입니다 준원이 말고 플레이어가 없으면 바로 이기는 경우입니다

반응형

댓글