๐ฅSilver 5 https://www.acmicpc.net/problem/10815 โ
1์ฐจ ํ์ดimport sysinput=sys.stdin.readlineanswer=''n=int(input())having_cards=set(map(int,input().rstrip().split()))m=int(input())num_list=list(map(int,input().rstrip().split()))for num in num_list: if num in having_cards: answer+='1' else: answer+='0'print(' '.join(answer))input์ ๋ฒ์๊ฐ 10^7์ผ๋ก ์ด๋ถํ์์ ํด์ผํ๋ ํ์ง๋ง, ์ผ๋จ ํ๋ฒ ์ ์งํ๊ฒ ํ์ด๋ณด์๋ค.์๊ทผ์ด..
์ฝ๋ฉํ ์คํธ
https://school.programmers.co.kr/learn/courses/30/lessons/42747 ํ๋ก๊ทธ๋๋จธ์ค์ฝ๋ ์ค์ฌ์ ๊ฐ๋ฐ์ ์ฑ์ฉ. ์คํ ๊ธฐ๋ฐ์ ํฌ์ง์
๋งค์นญ. ํ๋ก๊ทธ๋๋จธ์ค์ ๊ฐ๋ฐ์ ๋ง์ถคํ ํ๋กํ์ ๋ฑ๋กํ๊ณ , ๋์ ๊ธฐ์ ๊ถํฉ์ด ์ ๋ง๋ ๊ธฐ์
๋ค์ ๋งค์นญ ๋ฐ์ผ์ธ์.programmers.co.kr โ
์ ๋ตํ์ด (Python)def solution(citations): citations.sort(reverse=True) h=0 for i in range(len(citations)): if citations[i]>=i+1: h=i+1 return hh๋ฒ ์ด์ ์ธ์ฉ๋ ๋
ผ๋ฌธ์ด hํธ์ด์์ด๋ผ๋ ์กฐ๊ฑด์ ๋ง์กฑํ๋ h๊ฐ ์ค, ์ ์ผ ํฐ h๊ฐ์ ์ฐพ์์ผํ..
https://school.programmers.co.kr/learn/courses/30/lessons/159994 ํ๋ก๊ทธ๋๋จธ์ค์ฝ๋ ์ค์ฌ์ ๊ฐ๋ฐ์ ์ฑ์ฉ. ์คํ ๊ธฐ๋ฐ์ ํฌ์ง์
๋งค์นญ. ํ๋ก๊ทธ๋๋จธ์ค์ ๊ฐ๋ฐ์ ๋ง์ถคํ ํ๋กํ์ ๋ฑ๋กํ๊ณ , ๋์ ๊ธฐ์ ๊ถํฉ์ด ์ ๋ง๋ ๊ธฐ์
๋ค์ ๋งค์นญ ๋ฐ์ผ์ธ์.programmers.co.kr โ
์ ๋ต ํ์ด Queue (Python)# ๊ฐ์ฅ ๋งจ์ ์์๊ฐ ๋น ์ ธ๋๊ฐ์ผ ๋ค์ ์์๊ฐ ๋น ์ ธ๋๊ฐ ์ ์์ผ๋ฏ๋ก -> queue ์ฌ์ฉfrom collections import dequedef solution(cards1, cards2, goal): first_cards=deque(cards1) sec_cards=deque(cards2) for word in goal: if fi..
https://school.programmers.co.kr/learn/courses/30/lessons/42628 ํ๋ก๊ทธ๋๋จธ์ค์ฝ๋ ์ค์ฌ์ ๊ฐ๋ฐ์ ์ฑ์ฉ. ์คํ ๊ธฐ๋ฐ์ ํฌ์ง์
๋งค์นญ. ํ๋ก๊ทธ๋๋จธ์ค์ ๊ฐ๋ฐ์ ๋ง์ถคํ ํ๋กํ์ ๋ฑ๋กํ๊ณ , ๋์ ๊ธฐ์ ๊ถํฉ์ด ์ ๋ง๋ ๊ธฐ์
๋ค์ ๋งค์นญ ๋ฐ์ผ์ธ์.programmers.co.kr โ
1์ฐจ ํ์ด import heapqdef solution(operations): heap = [] for operation in operations: [inst, value] = operation.split(' ') value = int(value) if inst == 'I': # heap ์ฝ์
heapq.hea..
https://school.programmers.co.kr/learn/courses/30/lessons/42626?language=python3 ํ๋ก๊ทธ๋๋จธ์ค์ฝ๋ ์ค์ฌ์ ๊ฐ๋ฐ์ ์ฑ์ฉ. ์คํ ๊ธฐ๋ฐ์ ํฌ์ง์
๋งค์นญ. ํ๋ก๊ทธ๋๋จธ์ค์ ๊ฐ๋ฐ์ ๋ง์ถคํ ํ๋กํ์ ๋ฑ๋กํ๊ณ , ๋์ ๊ธฐ์ ๊ถํฉ์ด ์ ๋ง๋ ๊ธฐ์
๋ค์ ๋งค์นญ ๋ฐ์ผ์ธ์.programmers.co.kr โ 1์ฐจ ํ์ดimport heapqmin_heap = []def solution(scoville, K): heapq.heapify(scoville) count = 0 while scoville: # popํ ๊ฐ์ด k์ด์์ด๋๋ฉด, while ์ข
๋ฃ min_value = heapq.heappop(scoville) if mi..
๐ฅ Gold4 https://www.acmicpc.net/problem/10282 โ
์ ๋ต ํ์ดfrom sys import stdinfrom heapq import heappop,heappushinput = stdin.readlinet=int(input())INF=float('inf')def dijkstra(start): dist=[INF]*len(graph) dist[start]=0 q=[(0,start)] while q: cost,idx=heappop(q) if dist[idx] โจ ๊ฒฝ๋ก๋ ์๋ฐฉํฅ์ด ์๋์ง๋ง ๊ฐ์ผ์ ์ญ๋ฐฉํฅ์ผ๋ก ํผ์ ธ๋๊ฐ๊ธฐ ๋๋ฌธ์ ๊ทธ๋ํ์ ๊ฐ์ ๋ฃ์ด์ค๋ ์ญ๋ฐฉํฅ์ผ๋ก ๋ฃ์ด์ฃผ๋ฉด ๋๋ค.๊ทธ๋ ๊ฒ๋๋ฉด, ๊ฐ์ผ๋ ์ปดํจํฐ์ ๊ฐ์๋ ๋ค์ต์คํธ๋ผ ๊ฒฐ๊ณผ๊ฐ์ผ๋ก..
๐ฅ Gold4https://www.acmicpc.net/problem/1753 โ
์ ๋ตํ์ดimport sysfrom heapq import *input=sys.stdin.readlineINF=float('inf')def dijkstra(start): dist=[INF]*len(graph) dist[start]=0 #์์์ ๊ฑฐ๋ฆฌ๋ 0 q=[(0,start)] #(cost,๋
ธ๋๋ฒํธ) while q: cost,idx=heappop(q) if dist[idx] ์ฐ์ ์์ ํ๋ฅผ ์ด์ฉํ ๋ค์ต์คํธ๋ผ ์ต๋จ ๊ฒฝ๋ก ์๊ณ ๋ฆฌ์ฆ โ๏ธ์ ์ฒด ๋
ธ๋์ ๊ฐ์๊ฐ 10,000๊ฐ ์ด์์ด๋ผ๋ฉด, ๋ฆฌ์คํธ๊ฐ ์๋ ์ฐ์ ์์ ํ(ํ)์ ์ฌ์ฉํด ๋ฌธ์ ๋ฅผ ํ์ด์ผํ๋ค. ๐๐ป ๋ค์ต์คํธ๋ผ ์๊ณ ๋ฆฌ์ฆ ์๊ฐ ..
๐ฅ Silver3https://www.acmicpc.net/problem/8911 โ
์ ๋ตํ์ดimport sysinput = sys.stdin.readlinen = int(input()) dx = [0, 1, 0, -1]dy = [1, 0, -1, 0]for _ in range(n): commands = input().strip() direction = 0 # ์ด๊ธฐ๋ฐฉํฅ=๋ถ์ชฝ (0: ๋ถ, 1: ๋, 2: ๋จ, 3: ์) x, y = 0, 0 # ์ด๊ธฐ์์น min_x, min_y = 0, 0 max_x, max_y = 0, 0 for command in commands: if command == 'F': x += dx[di..