코딩 테스트/SWEA(11)
-
SWEA 2930. 힙
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV-Tj7ya3jYDFAXr SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 전체 코드 import heapq T = int(input()) print_num_list = [] for testcase in range(1, T + 1): heap = [] print_nums = [testcase] N = int(input()) for _ in range(N): read_line = input() # x를 힙에 넣어라 if len(read_line) > 2: cmd, num =..
2024.03.18 -
SWEA 5658. 보물상자 비밀번호
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWXRUN9KfZ8DFAUo SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 전체 코드 import collections def solution(lock_nums: collections.deque, k): num_set = set() divide = len(lock_nums) // 4 while True: should_rotate = False for i in range(0, len(lock_nums), divide): num = [] for j in range(i, i +..
2024.03.18 -
SWEA 13736. 사탕 분배
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AX8BB5d6T7gDFARO&categoryId=AX8BB5d6T7gDFARO&categoryType=CODE&problemTitle=13736&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=&pageSize=10&pageIndex=1&&&&&&&&& SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 전체 코드 def power(K, sum): if K == 1: return 2 ret = power(K // 2, sum) ..
2024.03.18 -
SWEA 5215. 햄버거 다이어트
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWT-lPB6dHUDFAVT SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 전체 코드 class Solution: def __init__(self): self.max_score = 0 def do(self, materials, limit_cal): # (점수, 칼로리) def dfs(path, start): score, cal = path if cal self.max_score: self.max_score = score for i..
2024.03.07 -
SWEA 1217. 거듭제곱
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14dUIaAAUCFAYD SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 전체 코드 # Code def involution(n, m): if m < 2: return n result = n * involution(n, m - 1) return result # ---- submit ---- T = 10 for test_case in range(1, T + 1): t_num = int(input()) n, m = map(int, input().split(' ')) resul..
2024.03.07 -
SWEA 2817. 부분 수열의 합
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV7IzvG6EksDFAXB SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 전체 코드 # Code def solution(nums: list, k): results = [] def dfs(path, start, k): num_sum = sum(path) if num_sum == k: results.append(path) return elif num_sum > k: return for i in range(start, len(nums)): dfs(path + [nums[i]]..
2024.03.07