์ฝ”๋”ฉํ…Œ์ŠคํŠธ

๐Ÿฅˆ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..
Yuuuki
'์ฝ”๋”ฉํ…Œ์ŠคํŠธ' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก