[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
[Python] 5202. 화물도크 for idx in range(1, int(input())+1): n = int(input()) # 신청서 n time = [tuple(map(int, input().split())) for _ in range(n)] # 작업 끝나는 시간을 기준으로 오름차순 정렬 # 빨리 끝나는 작업을 앞으로 둬야 계산을 많이 해볼 수 있기 때문이다. time.sort(key=lambda x: x[1]) answer = 0 temp_e = 0 # 이전 작업의 종료 시간 for s, e in time: if temp_e Algorithm/SW Expert Academy 2021.10.05
[Python] 5201. 컨테이너운반 tc = int(input()) for idx in range(1, tc+1): n, m = map(int, input().split()) # 컨테이너 수 n, 트럭 수 m weight = sorted(list(map(int, input().split())), reverse=True) # 화물의 무게 trucks = sorted(list(map(int, input().split()))) # 트럭의 적재 용량(pop쓸거라서 reverse 안씀) total_w = 0 t = trucks.pop() # 큰 트럭 가져와 for w in weight: # 화물 무거운 것부터 탐색 if w Algorithm/SW Expert Academy 2021.10.05