Algorithm/Softeer
import sys input = sys.stdin.readline # ๋ฐฐ๋ญ ๋ฌด๊ฒ ์ ํ W , n์ข
๋ฅ์ ๊ท๊ธ์ # ๊ฐ์ฅ ๋์ ๊ฐ๊ฒฉ์ผ๋ก ๋ฐฐ๋ญ ์ฑ์ฐ๊ธฐ w,n = map(int,input().split()) total_price = 0 #๋ฆฌ์คํธ ์ปดํ๋ฆฌํจ์
arr = [list(map(int,input().split())) for _ in range(n)] arr.sort(key = lambda x:x[1],reverse=True) idx = 0 while w>0: if arr[idx][0] >= w: total_price += arr[idx][1]*w break else: total_price += arr[idx][0]*arr[idx][1] w -= arr[idx][0] idx += 1 print(total_..
Algorithm/Softeer
import sys n = int(input()) line_dot = 2 for _ in range(n): line_dot += line_dot-1 print(line_dot**2) ์ ํ์์ ๊ตฌํ์ฌ ํ์ด
Algorithm/Softeer
import sys arr = list(map(int,input().split())) asc = list(range(1,9)) desc = list(range(8,0,-1)) result = "" if arr==asc: result = "ascending" elif arr==desc: result = "descending" else: result = "mixed" print(result)
Algorithm/Softeer
import sys input = sys.stdin.readline n,k = map(int,input().split()) line = list(input()) check = [0]*n # P:๋ก๋ด , H:๋ถํ for i in range(n): if line[i] == "P": for j in range(i-k,i+k+1): if (i==j) or (j=n): continue if line[j] == "H" and check[j] == 0 : check[j] = 1 break print(sum(check)) N์ 20000๋ณด๋ค ์๊ณ , K๋ 10๋ณด๋ค ์๊ธฐ ๋๋ฌธ์ ์์ ํ์ ๊ฐ๋ฅ ์ธ๋ฑ์ค i ๊ธฐ์ค์ผ๋ก ์์์ผ๋ก ์ฒดํฌ i == j (๋ก๋ด ์๊ธฐ ์์ ์ ์์น X) j๊ฐ ์์ญ ๋ฐ (์์์ผ๋ก ์ฒดํฌ) continue์ฒ๋ฆฌ c..
Algorithm/Softeer
import sys input = sys.stdin.readline from itertools import permutations # ๋ ์ผ์ ์์๋ฅผ ์กฐ์ํด์ ์ต์ํ์ ๋ฌด๊ฒ๋ง ๋ค ์ ์๊ฒ ํ์ n,m,k = map(int,input().split()) # n : ๋ ์ผ / m : ํ๋ฐฐ ๋ฌด๊ฒ / k : ์ํ ํ์ result = 100000 # ์ต์๋ฌด๊ฒ rail = list(map(int,input().split())) rail_list = list(permutations(rail)) # ์์ด def cal(current): total_weight, weight = 0, current[0] idx, cnt = 0, 0 while cnt < k: next_weight = current[(idx+1)%n] if ..
Algorithm/Softeer
import sys input = sys.stdin.readline # ์ํ๊ธฐ์ ์ด k๊ฐ์ ๋ฒํผ ์กด์ฌ (1~k) # ๋น๋ฐ๋ฒํธ = m๊ฐ์ ๋ฒํผ ์์๋๋ก ๋๋ฅด๊ธฐ # ์ฌ์ฉ์๊ฐ n๊ฐ์ ๋ฒํผ ๋๋ฆ m, n, k = map(int,input().split()) password_list = input().split() client_list = input().split() password = "" client = "" for x in password_list: password += x for x in client_list: client += x if password in client: print("secret") else: print("normal") join ํจ์๋ฅผ ์ฌ์ฉํ์ง ์์ ์ฝ๋๊ฐ ๊ธธ์ด์ง ๋ฌธ์์ด ํฉ์น๊ธฐ - jo..
Algorithm/Softeer
๋ฐฐ์ด 1์นธ์ 1m๋ก ์๊ฐํ๊ณ ๊ฐ ๋ฐฐ์ด๋ง๋ค ์ ํ ์๋๋ฅผ ์ง์ ํ์๋ค. import sys input = sys.stdin.readline # ์ ํ ์๋๋ฅผ ๊ฐ์ฅ ํฌ๊ฒ ๋ฒ์ด๋ ๊ฐ์ ์ถ๋ ฅ # ์ ํ ์๋๋ฅผ ๋ฒ์ด๋์ง ์์ ๊ฒฝ์ฐ๋ 0์ ์ถ๋ ฅ sec_list = [] test_list = [] sec_n,test_m = map(int,input().split()) for _ in range(sec_n): a,b = map(int,input().split()) for _ in range(a): sec_list.append(b) for _ in range(test_m): a,b = map(int,input().split()) for _ in range(a): test_list.append(b) result = 0 # ์ ํ ..
Algorithm/Softeer
8์ ๋ชจ์์ ์ ๊ตฌ ๋ฌถ์ - 0๋ถํฐ 9๊น์ง์ ์ซ์๋ฅผ ํํ ์ ๊ตฌ๊ฐ ์ผ์ก์ผ๋ฉด ๊ฒ์ ์(1), ๊บผ์ก์ผ๋ฉด ์
์ ํ์(0)์ผ๋ก ํํ import sys input = sys.stdin.readline info = { '0' : '1110111', '1' : '0010010', '2' : '1011101', '3' : '1011011', '4' : '0111010', '5' : '1101011', '6' : '1101111', '7' : '1110010', '8' : '1111111', '9' : '1111011', ' ' : '0000000' } T = int(input()) for _ in range(T): a,b = map(str,input().split()) #์ ์ฒ๋ฆฌ a_zero, b_zero = 5-len(a..