BOJ/๐ฅ18 โ Greedy Upper-Advanced I - 1 Solvedโ โ 1700 ๋ฉํฐํญ ์ค์ผ์ค๋ง โ โค๏ธ๐ฅ Optimal Page Replacement ์๊ณ ๋ฆฌ์ฆ์์ ์ฝ์ผํธ์ ์ฒ์์ผ๋ก ๊ผฝ๋ page fault ํ์๋ฅผ ์ ์ธํ page fault์ ํ์๋ฅผ ์ต์ํํ๋ ๋ฌธ์ โค๏ธ๐ฅ โ ์ฝ์ผํธ ์ฑ์ฐ๊ธฐ → โก ์ฝ์ผํธ์ ์กด์ฌํ์ง ์๋ ์ฒซ ๊ธฐ๊ธฐ ๋ฑ์ฅํ๋ฉด(page fault ์ํฉ) (1) ์ด๋ฏธ ์ฑ์ด ๊ธฐ๊ธฐ ์ค ์์ ์กด์ฌํ์ง ์๋ ๊ธฐ๊ธฐ๊ฐ ์๋ค๋ฉด ํด๋น ๊ธฐ๊ธฐ์ ๊ต์ฒด (2) ์๋ค๋ฉด ์ฝ์ผํธ ๊ธฐ๊ธฐ์ index ํ์ธํด ๊ฐ์ฅ ๋์ค์ ๋ฑ์ฅํ๋ ๊ธฐ๊ธฐ์ ๊ต์ฒด(greedy) import sys input=sys.stdin.readline N,K=map(int,input().split()) names=list(map(int,input().split())) ans=0 ps=[0]*N #power_strip in.. BOJ/๐ฅ 2023. 10. 18. โ BF Advanced I - 3 Solvedโ โ 14500 ํ ํธ๋ก๋ฏธ๋ ธ โ import sys input=sys.stdin.readline N,M=map(int,input().split()) tetris=[] for _ in range(N): tetris.append(list(map(int,input().split()))) ans=0 for i in range(N): for j in range(M): #1x4 if j BOJ/๐ฅ 2023. 10. 6. โ Greedy Advanced I - 4 Solvedโ โ 1744 ์ ๋ฌถ๊ธฐ โ import sys input=sys.stdin.readline N=int(input()) arr=[int(input()) for _ in range(N)] ans=0 pos,neg,zero,one=[],[],[],[] for n in arr: if n==0: zero.append(0) elif n==1: one.append(1) elif n>0: pos.append(n) else: neg.append(n) #1. don't tie ones ans+=len(one) #2.tie pos(from the biggest) pos.sort(reverse=True) for i in range(0,len(pos),2): if i==len(pos)-1:ans+=pos[i] else:ans+=.. BOJ/๐ฅ 2023. 8. 30. โ Sorting Advanced I - 5 Solvedโ โ 1083 ์ํธ โ import sys input=sys.stdin.readline N=int(input()) arr=list(map(int,input().split())) S=int(input()) for i in range(N): subarray_max = max(arr[i:i+S+1]) if arr[i] != subarray_max: subarray_max_index = arr.index(subarray_max) for j in range(subarray_max_index-i): arr[subarray_max_index-j], arr[subarray_max_index-j-1] = arr[subarray_max_index-j-1], arr[subarray_max_index-j] S-=(subarra.. BOJ/๐ฅ 2023. 7. 28. โ DP Advanced I - 4 Solvedโ โ 2591 ์ซ์์นด๋ โ n=input()l=len(n)if l==1:print(1)else: dp=[0]*l #dp-table initialization - dp[0], dp[1] dp[0]=1 front_two=int(n[:2]) if front_two =4: dp[i]=0 else: dp[i]=dp[i-2] print(dp[-1]) ๐ dp-table์ ์ ํ์ ์ธ dp ์ ํ ๋ต๊ฒ updateํ๋ ์ ํ์ด๋, ๋งจ ๋ง์ง๋ง ์ซ์๊ฐ 0์ผ ๊ฒฝ์ฐ์ ์์ธ๋ฅผ ์ฒ๋ฆฌํ๋ dp ์ ํ! ๐โ ๊ธธ์ด๊ฐ 1์ธ ๊ฒฝ์ฐ - ์ซ์ 1๊ฐ๋ก ์ด๋ฃจ์ด์ง ์นด๋ 1๊ฐ - dp[0] = 1 โก ๊ธธ์ด๊ฐ 2์ธ ๊ฒฝ์ฐ(1) ์.. BOJ/๐ฅ 2023. 1. 8. โ hashing ์๊ธ - 1๋ฌธ์ ()โ ๐ฅ hash ์ ๋ฆฌ ํฌ์คํ https://sh-avid-learner.tistory.com/194 ๐ฅ hashing ๊ฐ๋ ์์ฒด๊ฐ ๊ณ ๋์ด๋๋ก ์๊ธ ์ด์์ ๋์ด๋ ๋ฌธ์ ๋ก ๋ง์ด ๊ตฌ์ฑ๋์ด ์๋ค. hashing ๊ธฐ์ด๋ถํฐ ์๊ธ ๋ฌธ์ ๊น์ง ๋ชจ๋ ์์ธ๋ฌ ๋ฌธ์ ๋ฅผ ํ์ด๋ณด์ โ 15829 Hashing โ ๐ฅ ์ต๋ํ ์ถฉ๋์ด ์ ๊ฒ ์ผ์ด๋๊ฒ๋ ๋ง๋ hash function ๊ตฌํ ์ ํ → 1) ์์ด์๋ฌธ์๋ฌธ์์ด์์ (a๋ถํฐ ์์ํ๋ 0๋ฒ ~) 31์ ์ํ๋ฒณ ๋ฒํธ ์ง์์น → 2) input ๊ธธ์ด๊ฐ ์ฆ๊ฐํ ๋๋ง๋ค 0๋ถํฐ ์ปค์ง๋ ์ ์ → 1)๊ณผ 2)๋ฅผ ๊ณฑํ ๋์ ํฉ์ 1234567891์ ๋๋ ๋๋จธ์ง input() key = input() alphas = 'abcdefghijklmnopqrstuvwxyz' i,ans=0,0 for l in .. BOJ/๐ฅ 2022. 11. 6. ์ด์ 1 2 ๋ค์