[Programmers | Level 2] 프린터 (Python) from collections import deque def solution(priorities, location): printer = deque() result = [] for i in range(len(priorities)): printer.append([priorities[i], i]) while printer: MAX = 0 for i in printer: MAX = max(i[0], MAX) prior, document = printer.popleft() if prior < MAX: printer.append([prior, document]) else: result.append([prior, document]) for i in range(len(result)): if location == res.. Algorithm | SQL/Programmers 2021. 4. 30. 20:28
[Programmers | Level 2] 다리를 지나는 트럭 (Python) from collections import deque def solution(bridge_length, weight, truck_weights): truck_weights = deque(truck_weights) bridge = deque([0 for _ in range(bridge_length)]) t = 0 bridge_weight = 0 while len(bridge) != 0: pass_truck = bridge.popleft() bridge_weight -= pass_truck t += 1 if truck_weights: if bridge_weight + truck_weights Algorithm | SQL/Programmers 2021. 4. 30. 20:25
[BOJ 1194] 달이 차오른다, 가자 (Python) from collections import deque import sys input = sys.stdin.readline dx = [1, -1, 0, 0] dy = [0, 0, -1, 1] def bfs(): while q: x, y, key, cnt = q.popleft() for i in range(4): nx = x + dx[i] ny = y + dy[i] if 0 Algorithm | SQL/BOJ 2021. 4. 21. 16:43