Skip to content

Instantly share code, notes, and snippets.

View inspirit941's full-sized avatar

Donggeon Lee inspirit941

View GitHub Profile
import heapq
def solution(food_times, k):
# (음식 크기, 원판에서의 위치) 로 food_times 재정의
food_times = [(food, idx) for idx, food in enumerate(food_times, 1)]
# heapify. 음식 크기가 작은 순으로 뽑아낸다.
heapq.heapify(food_times)
# 가장 크기 작은 음식
small_food = food_times[0][0]
prev_food = 0
def solution(cacheSize, cities):
# 캐시 사이즈가 0이면, 모든 input이 전부 cache miss다.
if cacheSize == 0:
return len(cities) * 5
cache = []
runtime = 0
for city in cities:
city = city.lower()
# cache에 존재하지 않는 경우
import sys
from collections import deque
import heapq
n = int(sys.stdin.readline())
maps = []
for y in range(n):
arr = list(map(int, sys.stdin.readline().split()))
for x in range(len(arr)):
if arr[x] == 9:
start = (y, x, 0)
# -*- coding: utf-8 -*-
# UTF-8 encoding when using korean
from collections import deque
M, N = map(int, input().split())
maps = []
start = []
for y in range(N):
temp = list(map(int, input().split()))
for x in range(M):
# -*- coding: utf-8 -*-
# UTF-8 encoding when using korean
import sys
import heapq
from collections import defaultdict
n = int(sys.stdin.readline())
work_list = [list(map(int,sys.stdin.readline().replace("\n","").split())) for _ in range(n)]
# 날짜 순 오름차순 정렬
# ex) 현재가 7일이면, 마감일이 6일 이전인 일들을 작업할 수 없다.
# -*- coding: utf-8 -*-
# UTF-8 encoding when using korean
import sys
N = int(sys.stdin.readline())
M = int(sys.stdin.readline())
arr = [0 for _ in range(N+1)]
for _ in range(M):
idx = int(sys.stdin.readline())
arr[idx] = 1
import sys
import heapq
from collections import defaultdict
def solve(precede_list, build_next, time, target):
# 조건 없이 바로 만들 수 있는 건물들 찾기
queue = [(time[idx], idx) for idx in range(1, len(precede_list)) if precede_list[idx] == 0]
# 시간순서로 정렬. 가장 시간 짧은 것부터 뽑아내는 min heap 사용
heapq.heapify(queue)
import heapq
import sys
# 중앙값 기준으로 작은 값 = left, 큰 값 = right
left, right = [], []
n = int(sys.stdin.readline())
for _ in range(n):
num = int(sys.stdin.readline())
if len(left) == len(right):
# max_heap.
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the climbingLeaderboard function below.
def climbingLeaderboard(scores, alice):
#!/bin/python3
import math
import os
import random
import re
import sys
from collections import Counter
# Complete the isValid function below.