answer_set = set()
mx = 0
def dfs(depth, n ,arrow, info):
global mx
if depth == 11 and len(arrow) == 11:
if (sum(arrow) < n):
arrow[-1] += n - sum(arrow)
r_score, a_score = 0, 0
for i in range(11):
if int(info[i]) >= arrow[i] and int(info[i]) != 0:
a_score += 10 - i
elif int(info[i]) < arrow[i]:
r_score += 10 - i
if r_score > a_score:
if r_score - a_score >= mx:
answer_set.add((r_score - a_score, tuple(arrow)))
mx = max(mx, r_score - a_score)
return
if info[depth] + 1 <= n - sum(arrow):
arrow.append(int(info[depth] + 1))
dfs(depth+1, n, arrow, info)
arrow.pop()
arrow.append(0)
dfs(depth+1, n, arrow, info)
arrow.pop()
def solution(n, info):
answer = []
arrow = []
dfs(0, n, arrow, info)
s = list(sorted(answer_set, key = lambda x : (-x[0], -x[1][-1], -x[1][-2], -x[1][-3], -x[1][-4], -x[1][-5], -x[1][-6], -x[1][-7], -x[1][-8], -x[1][-9], -x[1][-10], -x[1][0])))
if len(answer_set) == 0:
answer.append(-1)
else:
answer = s[0][1]
return answer
- 어피치랑 라이언이 모두 0점일 때는 점수를 더하지 않아야 한다. → 여기서 시간 엄청 씀 ;;
- set에 리스트를 저장할 수 없다.. ! 그래서 arrow도 tuple로 바꿔서 저장함
- set은 인덱스로 접근할 수 없어서 리스트로 바꿔서 접근함