본문 바로가기

Algorithm

(33)
[Algorithm|Python] 백준 19598번 / 99클럽 20일차 TIL import sysimport heapq as hqinput = sys.stdin.readlinen = int(input())times = []for _ in range(n): times.append(list(map(int, input().split()))) times.sort(key=lambda x:x[0])arr = [0]count = 1for start, end in times: if start >= arr[0]: hq.heappop(arr) else: count += 1 hq.heappush(arr, end)print(count)
[Algorithm|Python] 백준 1946번 / 99클럽 19일차 TIL import sysinput = sys.stdin.readlineT = int(input())for _ in range(T): N = int(input()) rank = [list(map(int, input().split())) for _ in range(N)] rank_asc = sorted(rank) top = 0 result = 1 for i in range(1, len(rank_asc)): if rank_asc[i][1]
[Algorithm|Python] 백준 147503번 / 99클럽 18일차 from heapq import heappop, heappushimport sysinput = sys.stdin.readline N, M, K = map(int, input().split())beers = []for _ in range(K): v, c = map(int, input().split()) beers.append([v, c]) beers.sort(key=lambda x: x[1]) def solution(): picked = [] preference = 0 for b in beers: heappush(picked, b) preference += b[0] if len(picked) >= N: if prefere..
[Algorithm|Python] 백준 11399번 / 99클럽 17일차 TIL N = int(input())arr = list(map(int,input().split()))arr.sort()result=0time=0for i in range(N): time += arr[i] result += time print(result)
[Algorithm|Python] 백준 27961번 / 99클럽 16일차 TIL N = int(input())cnt = 1cat = 1if N == 0: print(0)else: while cat
[Algorithm|Python] 백준 15686번 / 99클럽 15일차 TIL N,M = map(int,input().split())min_ans = 99999999home = []chick = []for i in range(N): # 집과 치킨의 좌표를 리스트에 넣어준다. row = list(map(int,input().split())) for j in range(N): if row[j] == 1: home.append((i,j)) elif row[j]==2: chick.append((i,j))visited = [False] * len(chick)def dfs(idx,cnt): global min_ans if cnt == M: # print(visited[:]) ans ..
[Algorithm|Python] 백준 2615번 / 99클럽 14일차 TIL import sysboard = [list(map(int, sys.stdin.readline().split())) for _ in range(19)]move= [[1,0],[1,1],[0,1],[-1,1]]N = 19result = 0for i in range(N): for j in range(N): if board[i][j] != 0: stone = board[i][j] for dy, dx in move: ny, nx, cnt = i + dy, j + dx, 1 while 0 0: print(result) print(y+1,x+1..
[Algorithm|Python] 백준 2529번 / 99클럽 13일차 TIL def get_num(x, y, oper): if oper == ' y : return False else: if x