파이썬47 백준 13701번 : 중복 제거 (Python) 출처 : https://www.acmicpc.net/problem/13701 import sys arr = bytearray(2**22) s = "" while True : c = sys.stdin.read(1) if c.isnumeric() : s += c else : n = int(s) d = n // 8 r = n % 8 if not arr[d] & (1 2023. 3. 20. 백준 19585번 : 전설 (Python) (트라이 없이) 출처 : https://www.acmicpc.net/problem/19585 import sys input = sys.stdin.readline c, n = map(int, input().split()) tree_c = dict() set_n = set() def insert(tree, word) : cur = tree for char in word : if char not in cur : cur[char] = dict() cur = cur[char] cur["*"] = len(word) def startswith(tree, word) : cur = tree for char in word : if char not in cur : return False cur = cur[char] if "*" in cur.. 2023. 3. 14. 백준 1991번 : 트리 순회 (Python) (비재귀 반복문) 출처 : https://www.acmicpc.net/problem/1991 n = int(input()) graph = dict() for _ in range(n) : node, left, right = input().split() graph[node] = [left, right] def preorder_stack(node) : answer = list() stack = [node] while stack : node = stack.pop() # 루트 노드 방문 answer.append(node) # 오른쪽 자식 노드 있으면 스택에 삽입 if graph[node][1] != "." : stack.append(graph[node][1]) # 왼쪽 자식 노드 있으면 스택에 삽입 if graph[node][0].. 2023. 3. 3. 백준 13904번 : 과제 (Python) 출처 : https://www.acmicpc.net/problem/13904 n = int(input()) hw = [] max_d = 0 for _ in range(n) : d, w = map(int, input().split()) hw.append((w, d)) max_d = max(max_d, d) hw.sort() arr = [0] * (max_d + 1) answer = 0 while hw : w, d = hw.pop() for i in range(d, 0, -1) : if arr[i] == 0 : arr[i] = w answer += w break print(answer) 두 가지 풀이가 있다. 먼저 남은 일수와 점수를 입력 받아 hw에 저장하고, 점수가 낮은 순으로 정렬한다. 또한 입력 과정.. 2023. 2. 26. 이전 1 2 3 4 5 ··· 12 다음