전체 글 87

[SWEA/Python] 1486. 장훈이의 높은 선반

1. 이중 for문'3752. 가능한 시험 점수'랑 똑같이 풀이했어요 ~!!비슷한 문제 연습하시는 분들 참고하세용T = int(input())for test_case in range(1, T + 1): N, B = map(int, input().split()) S = list(map(int, input().split())) answer = [0] temp = [0] for i in range(N): for j, val in enumerate(answer): temp.append(S[i] + answer[j]) answer = list(set(temp)) answer.sort() for i in answ..

[SWEA/Python] 3752. 가능한 시험 점수

성공코드) 이중 for문T = int(input())for test_case in range(1, T + 1): N = int(input()) arr = list(map(int, input().split())) result = [0] temp = [0] for i in range(N): for j, val in enumerate(result): temp.append(result[j]+arr[i]) result = list(set(temp)) print(f'#{test_case} {len(result)}') 실패1) combinations (시간초과)가장 먼저 떠오른건 combinations를 사용하는 것이었다.하지만 ..

[SWEA/Python] 5215. 햄버거 다이어트(D3)

가능한 모든 조합을 구한 뒤, 칼로리(L)보다 낮으면서 맛의 만족도가 가장 높은 score를 구했습니다.빡구현으로도 메모리 통과하는 문제! from itertools import combinationsT = int(input())for test_case in range(1, T + 1): N, L = map(int, input().split()) array = [] score = 0 for _ in range(N): t, k = map(int, input().split()) array.append((t,k)) for i in range(N, 0, -1): comb = combinations(array, i) for j i..

[백준 - Python] 32405. 배틀 로얄

문제링크 최종코드(코드링크)단순 구현으로 풀어봤습니당 .. N = int(input())d = list(map(int, input().split())) # 공격력h = list(map(int, input().split())) # 체력cur, num = 0, Nwhile True: ccur = cur % 4 if num == 1: # 한명만 생존 print(ccur) break elif h[ccur] == 0: # 체력이 없으면 공격 진행 X cur += 1 continue # 공격 for i in range(N): if h[i] == 0 or i == ccur: continue # 공격 대상의 체력이 0이거나 자신 ..