[Python] 1486. 장훈이의 높은 선반 def bfs(i, top_h): global answer if b Algorithm/SW Expert Academy 2021.10.09
[Python] 쉬운 거스름돈 money = [50000, 10000, 5000, 1000, 500, 100, 50, 10] # S마켓에서 사용하는 돈의 종류 tc = int(input()) for idx in range(1, tc+1): target = int(input()) # 손님에게 거슬러 주어야 할 금액 used = [0 for _ in range(8)] # 돈 종류 별로 몇개씩 필요한지 저장할 배열 for i in range(8): if money[i] Algorithm/SW Expert Academy 2021.10.08
[Python] 1861. 정사각형 방 DFS 코드 dx = [1, -1, 0, 0] dy = [0, 0, 1, -1] def dfs(y, x, room, cnt): global move move = max(move, cnt) # 이동 갱신 for i in range(4): ny = y + dy[i] nx = x + dx[i] # 범위 내에 있고 지금 방보다 1크다면 if 0 Algorithm/SW Expert Academy 2021.10.08
[Python] 2819. 격자판 이어붙이기 dx = [1, -1, 0, 0] dy = [0, 0, 1, -1] def recur(cnt, y, x, num): global numbers if cnt == 7: # 여섯번 이동했다면 numbers.add(num) # 리스트에 더해 return for i in range(4): ny = y + dy[i] nx = x + dx[i] if 0 Algorithm/SW Expert Academy 2021.10.08
[Python] 1865. 동철이의 일분배 def recur(idx, total): global answer if idx == n: # 일 배분 다 했다면 answer = max(answer, total) # 최대 확률로 갱신 return if total Algorithm/SW Expert Academy 2021.10.07
[Python] 5209. 최소 생산 비용 def recur(idx, total): global answer if idx == n: # 공장 다 돌았다면 answer = min(answer, total) # 최소비용으로 갱신 return if answer Algorithm/SW Expert Academy 2021.10.07
[Python] 5208. 전기버스2 코드 1 def recur(now, cnt, battery): global answer battery -= 1 # 배터리 감소 if now == n-1: # 마지막 정류장까지 온 경우 answer = min(answer, cnt) # 작은 횟수로 갱신 return if answer Algorithm/SW Expert Academy 2021.10.07
[Python] 5207. 이진탐색 for idx in range(1, int(input())+1): n, m = map(int, input().split()) a = sorted(list(map(int, input().split()))) # 리스트 a 정렬 b = list(map(int, input().split())) # 체크할 숫자들이 들어가있는 리스트 b answer = 0 for t_n in b: # t_n : target number s = 0 # 시작 인덱스 e = n - 1 # 마지막 인덱스 switch = None # 이전에 탐방한 구간이 어딘지 while s t_n and switch != 'l': # t_n이 중간 지점 숫자보다 작고, 이전 방향 왼쪽 아니었다면 e = mid - 1 # 다음은 왼쪽 구간 탐방 하도록 s.. Algorithm/SW Expert Academy 2021.10.07
[Python] 5205. 퀵 정렬 def partition(l, r): p = arr[l] # 피봇 설정 i, j = l, r while i Algorithm/SW Expert Academy 2021.10.07
[Python] 5203. 베이비진 게임 카드를 하나씩 추가해가며 검토하는 코드 # babygin인지 확인하는 함수 def is_babygin(p_cards, n): for i in range(n-2): if p_cards[i] + 1 in p_cards and p_cards[i] + 2 in p_cards: # run 인가요 ? return True elif p_cards[i] == p_cards[i+1] == p_cards[i+2]: # triplet 인가요? return True return False # 암것도 아니야 for idx in range(1, int(input())+1): cards = list(map(int, input().split())) player1 = [] player2 = [] answer = 0 for i in r.. Algorithm/SW Expert Academy 2021.10.05