Algorithm

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

Algorithm/Softeer

[Softeer - level1] ๋ฌธ์ œํ’€์ด

์ฃผํ–‰๊ฑฐ๋ฆฌ ๋น„๊ตํ•˜๊ธฐ import sys input = sys.stdin.readline a,b = map(int,input().split()) result = "" if a>b: result = "A" elif a

Algorithm/SWEA

[SWEA - D3] 1954. ๋‹ฌํŒฝ์ด ์ˆซ์ž

๋‚˜์˜ ์ฝ”๋“œ # ์šฐ -> ํ•˜ -> ์ขŒ -> ์ƒ dr = [0, 1, 0, -1] dc = [1, 0, -1, 0] T = int(input()) for t in range(1,T+1): n = int(input()) arr = [[0]*n for _ in range(n)] r = 0 c = 0 dist = 0 for i in range(1,n*n+1): arr[r][c] = i r += dr[dist] c += dc[dist] if r = n or c >= n or arr[r][c] != 0 : r -= dr[dist] c -= dc[dist] dist = (dist +1) % 4 r += dr[dist] c += dc[dist] print("#"+str(t)) for x..

Algorithm/SWEA

[SWEA - D3] ๋ฌธ์ œํ’€์ด

์ •๋‹ต์œจ ๋†’์€ ๋ฌธ์ œ ํ’€์ด๋“ค 3314. ๋ณด์ถฉํ•™์Šต๊ณผ ํ‰๊ท  T = int(input()) for t in range(1, T + 1): arr = list(map(int,input().split())) res = [] for x in arr: if x < 40 : res.append(40) else: res.append(x) print("#"+str(t) , sum(res)//5 ) 9700. USB ๊ฝ‚๊ธฐ์˜ ๋ฏธ์Šคํ„ฐ๋ฆฌ T = int(input()) for t in range(1,T+1): p,q = map(float,input().split()) s1 = (1-p) * q s2 = p*(1-q)*q if s1 < s2: res = "YES" else: res = "NO" print("#"+str(t) , res ..

Algorithm/SWEA

[SWEA - D3] 5215. ํ–„๋ฒ„๊ฑฐ ๋‹ค์ด์–ดํŠธ

๋‚˜์˜ ์ฝ”๋“œ def DFS(L,score,kcal): global res if kcal > k: return if score > res: res = score if L == n: return s,c = arr[L] DFS(L+1,score+s, kcal+c) DFS(L+1,score,kcal) T = int(input()) for t in range(1,T+1): n,k = map(int,input().split()) arr = [] res = 0 for _ in range(n): a,b = map(int,input().split()) arr.append((a,b)) DFS(0,0,0) print("#"+str(t) , res ) DFS ๋ฅผ ์ด์šฉํ•œ ํ’€์ด ํ–„๋ฒ„๊ฑฐ ์žฌ๋ฃŒ์ˆ˜(n), ๋„˜์ง€ ๋ง์•„์•ผ ํ•˜๋Š” ์นผ๋กœ๋ฆฌ์ˆ˜(k)..

Algorithm/SWEA

[SWEA - D3] 5431. ๋ฏผ์„์ด์˜ ๊ณผ์ œ ์ฒดํฌํ•˜๊ธฐ

๋‚˜์˜ ์ฝ”๋“œ T = int(input()) for t in range(1,T+1): n,k = map(int,input().split()) arr = list(map(int,input().split())) print("#"+str(t) , end=" ") for i in range(1,n+1): if i not in arr: print(i , end=" ") print() ๊ณผ์ œ๋ฅผ ์ œ์ถœํ•˜์ง€ ์•Š์€ ์‚ฌ๋žŒ์˜ ๋ฆฌ์ŠคํŠธ๋ฅผ ๋งŒ๋“ค์–ด์„œ append ํ•˜๊ณ  ๋งˆ์ง€๋ง‰์— ์ถœ๋ ฅํ•ด๋„ ๋˜๊ฒ ๋‹ค.

hello_u
'Algorithm' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (2 Page)