์ „์ฒด ๊ธ€

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 ํ•˜๊ณ  ๋งˆ์ง€๋ง‰์— ์ถœ๋ ฅํ•ด๋„ ๋˜๊ฒ ๋‹ค.

Algorithm/SWEA

[SWEA - D3] 2805. ๋†์ž‘๋ฌผ ์ˆ˜ํ™•ํ•˜๊ธฐ

๋‚˜์˜ ์ฝ”๋“œ t = int(input()) for tc in range(1,t+1): n = int(input()) lt = n//2 rt = n//2 result = 0 for _ in range(n//2): arr = list(map(int,input())) result += sum(arr[lt:rt+1]) lt -= 1 rt += 1 for _ in range(n//2,n): arr = list(map(int,input())) result += sum(arr[lt:rt+1]) lt += 1 rt -= 1 print("#"+str(tc) , result ) ์ฝ”๋“œ๊ฐ€ ๋„ˆ๋ฌด ์ง€์ €๋ถ„ํ•ด์„œ ๋‹ค์‹œ ํ’€์—ˆ๋‹ค. ์ˆ˜์ •์ฝ”๋“œ t = int(input()) for tc in range(1,t+1): n = int(input()..

Algorithm/SWEA

[SWEA - D3] 1209. Sum

๋‚˜์˜ ์ฝ”๋“œ for _ in range(10): t = int(input()) arr = [] for _ in range(100): tmp = list(map(int,input().split())) arr.append(tmp) large = 0 c = [] d = [] for i in range(100): if sum(arr[i]) > large : large = sum(arr[i]) b = [j[i] for j in arr] if sum(b) > large : large = sum(b) c.append(arr[i][i]) d.append(arr[i][99-i]) result = max(large,sum(c),sum(d)) print("#"+str(t) , result) ํ–‰, ์—ด, ๋Œ€๊ฐ์„ 1, ๋Œ€๊ฐ์„ 2 ๊ฐ๊ฐ..

Algorithm/SWEA

[SWEA - D3] 1234. ๋น„๋ฐ€๋ฒˆํ˜ธ

๋‚˜์˜ ์ฝ”๋“œ for t in range(1, 11): n,s = input().split() n = int(n) + 2 arr = list(s) flag = True while flag: n -= 2 for i in range(n-1): if arr[i] == arr[i+1]: arr.pop(i) arr.pop(i) break else: flag = False print("#"+str(t) ," ", *arr , sep="") ๋ฐฐ์—ด์—์„œ ๋ฐ˜๋ณต๋ฌธ์„ ์ˆ˜ํ–‰ํ•˜์—ฌ ๋‹ค์Œ ์ธ๋ฑ์Šค์™€ ๊ฐ’์ด ๊ฐ™์œผ๋ฉด ๋‘˜๋‹ค ์†Œ๊ฑฐ pop() ๋ฐ˜๋ณต๋ฌธ์˜ ๊ธธ์ด๋„ ๊ฐ์†Œ์‹œํ‚ด n -= 2 ๋ฐฐ์—ด์—์„œ ๋”์ด์ƒ ์†Œ๊ฑฐํ•  ๋ฒˆํ˜ธ ์Œ์ด ์—†์œผ๋ฉด while ๋ฐ˜๋ณต๋ฌธ์„ ์ข…๋ฃŒ ์‹œํ‚ค๊ธฐ ์œ„ํ•ด flag ๋ณ€์ˆ˜๋ฅผ ์ด์šฉ for-else ๋ฌธ for i in range(5): print(i, ..

hello_u
๐Ÿ˜œ