def solution(k, dungeons): answer = -1 whole_case = [] for a in range(len(dungeons)): A = k Al = [] Al.append(a) if A >= dungeons[a][0]: A -= dungeons[a][1] for b in range(len(dungeons) - 1): B = A Bl = Al Bl.append(b) if b in Bl: whole_case.append(len(Bl) - 1) else: if B >= dungeons[b][0]: B -= dungeons[b][1] for c in range(len(dungeons) - 2): C = B Cl = Bl Cl.append(c) if c in Cl: whole_case.append(len(Cl) - 1) else: if C >= dungeons[c][0]: C -= dungeons[c][1] for d in range(len(dungeons) - 3): D = C Dl = Cl Dl.append(d) if d in Dl: whole_case.append(len(Dl) - 1) else: if D >= dungeons[d][0]: D -= dungeons[d][1] for e in range(len(dungeons) - 4): E = D El = Dl El.append(e) if e in El: whole_case.append(len(El) - 1) else: if E >= dungeons[e][0]: E -= dungeons[e][1] for f in range(len(dungeons) - 5): F = E Fl = El Fl.append(f) if f in Fl: whole_case.append(len(Fl) - 1) else: if F >= dungeons[f][0]: F -= dungeons[f][1] for g in range(len(dungeons) - 6): G = F Gl = Fl Gl.append(g) if g in Gl: whole_case.append(len(Gl) - 1) else: if G >= dungeons[g][0]: G -= dungeons[g][1] for h in range(len(dungeons) - 7): H = G Hl = Gl Hl.append(h) if h in Hl: whole_case.append(len(Hl) - 1) else: if H >= dungeons[h][0]: H -= dungeons[h][1] whole_case.append(len(Hl)) else: whole_case.append(len(Hl) - 1) else: whole_case.append(len(Gl) - 1) else: whole_case.append(len(Fl) - 1) else: whole_case.append(len(El) - 1) else: whole_case.append(len(Dl) - 1) else: whole_case.append(len(Cl) - 1) else: whole_case.append(len(Bl) - 1) else: whole_case.append(len(Al) - 1) print(whole_case) return answersolution(80, [[80,20],[50,40],[30,10]])
top of page
실제 작동 상태를 확인하려면 라이브 사이트로 이동하세요.
2024-02-18
2024-02-18
댓글 0개
좋아요
댓글(0)
bottom of page