๐Ÿ˜œ

Algorithm/Softeer

[Softeer - level2] ๊ธˆ๊ณ ํ„ธ์ด

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

[Softeer - level2] ์ง€๋„ ์ž๋™ ๊ตฌ์ถ•

import sys n = int(input()) line_dot = 2 for _ in range(n): line_dot += line_dot-1 print(line_dot**2) ์ ํ™”์‹์„ ๊ตฌํ•˜์—ฌ ํ’€์ด

Algorithm/Softeer

[Softeer - level2] 8๋‹จ ๋ณ€์†๊ธฐ

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

[Softeer - level3] ์Šค๋งˆํŠธ ๋ฌผ๋ฅ˜

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

[Softeer - level3] ํƒ๋ฐฐ ๋งˆ์Šคํ„ฐ ๊ด‘์šฐ

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

[Softeer - level2] [21๋…„ ์žฌ์ง์ž ๋Œ€ํšŒ ์˜ˆ์„ ] ๋น„๋ฐ€ ๋ฉ”๋‰ด

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

[Softeer - level2] GBC

๋ฐฐ์—ด 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

[Softeer - level2] [21๋…„ ์žฌ์ง์ž ๋Œ€ํšŒ ์˜ˆ์„ ] ์ „๊ด‘ํŒ

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..

hello_u
'๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (3 Page)