1781 컵라면, 9663 N-Queen, 1987 알파벳
1781 컵라면, 9663 N-Queen, 1987 알파벳 1781 컵라면 import heapq n = int(input()) array = [] q = [] for _ in range(n): # take deadline, number of noodle and sorting x, y = map(int, input().split()) array.append((x, y)) array.sort() for i in array: # add noodles and if deadline over, delete minimum value in list a = i[0] heapq.heappush(q, i[1]) if a < len(q): heapq.heappop(q) print(sum(q)) - 두 원소 받아서 튜플로 정..
2020. 10. 14.
5585 거스름돈, 1439 뒤집기, 2012 등수 매기기
5585 거스름돈, 1439 뒤집기, 2012 등수 매기기 5585 거스름돈 # 첫번째 풀이 money_list = [500, 100, 50, 10, 5, 1] money = int(input()) money = 1000 - money count = 0 for i in money_list: if money < i: continue else: count += money // i money = money % i print(count) # 두번째 풀이(더 간단하게) money = 1000 - int(input()) count = 0 for i in [500, 100, 50, 10, 5, 1]: count += money // i money %= i print(count) 1439 뒤집기 s = input() ..
2020. 10. 12.
1012 유기농 배추, 1325 효율적인 해킹, 10282 해킹
1012 유기농 배추, 1325 효율적인 해킹, 10282 해킹 1012 유기농 배추 import sys sys.setrecursionlimit(100000) def dfs(v, w): visited[v][w] = True directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] for dx, dy in directions: nx, ny = v + dx, w + dy if nx = n or ny = m: continue if adj[nx][ny] and not visited[nx][ny]: dfs(nx, ny) for _ in range(int(input())): m, n, k = map(int, input().split()) visit..
2020. 10. 8.