It97 2309번 : 일곱 난쟁이 #일곱 난쟁이 import random dwarf=[] dwarf_7=[] result=0 for i in range(9): dwarf.append(int(input())) while 1: if (result ==100 and len(dwarf_7) == 7): break else: result=0 dwarf_7=[] for i in range(7): choice_7=random.choice(dwarf) if choice_7 in dwarf_7: choice_7=random.choice(dwarf) else: dwarf_7.append(choice_7) result=sum(dwarf_7) dwarf_7.sort() for i in dwarf_7: print(i) 2022. 7. 15. 226p.<실전 문제> : 효율적인 화폐 구성 # 효율적인 화폐 구성 n, m = map(int, input().split()) won = [] result = 0 count = 0 for i in range(n): won.append(int(input())) won.sort(reverse=True) while 1: if count == len(won): result = -1 break if m > 0: for i in won: if m-i >= 0: m -= i result += 1 count = 0 break else: count += 1 else: break print(result) 2022. 7. 14. 223p.<실전 문제> : 바닥 공사 # 바닥 공사 n = int(input()) if n > 2: nlist = [0 for _ in range(n+1)] nlist[1] = 1 nlist[2] = 3 for i in range(3, n+1): nlist[i] = nlist[i-1]+nlist[i-2]*2 print(nlist[n] % 796796) else: print(n % 796796) 2022. 7. 14. 220p.<실전문제> : 개미 전사 # 개미 전사 n = int(input()) foods = list(map(int, input().split())) result1 = 0 result2 = 0 a = 0 def delmax(x): a = x.index(max(x)) print(x) if len(x) > 1: if max(x) == x[-1]: x.remove(x[-1]) x.remove(x[a-1]) elif max(x) == x[0]: x.remove(x[a]) x.remove(x[a]) else: x.remove(x[a]) x.remove(x[a]) x.remove(x[a-1]) nn = n / 2 nn = int(nn) for i in range(nn): result1 += max(foods) delmax(foods) if n % .. 2022. 7. 13. 이전 1 2 3 4 5 6 ··· 25 다음