Algorithm

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

Algorithm/SWEA

[SWEA - D3] 3456. ์ง์‚ฌ๊ฐํ˜• ๊ธธ์ด ์ฐพ๊ธฐ

๋‚˜์˜ ์ฝ”๋“œ T = int(input()) for t in range(1, T + 1): arr = list(map(int,input().split())) cnt = [0]*101 result = 0 for x in arr: cnt[x] += 1 for i in range(len(cnt)): if cnt[i] ==1 or cnt[i] ==3 : result = i print("#"+str(t) , result) ์ž…๋ ฅ๋ฐ›์€ ์ˆ˜๋ฅผ ์นด์šดํŒ…ํ–ˆ๋‹ค. ์ง„์งœ ๋ฉ์ฒญํ•˜๊ฒŒ ํ’€์—ˆ๋‹ค. ์ฝ”๋“œ ์ˆ˜์ • T = int(input()) for t in range(1, T + 1): arr = list(map(int,input().split())) arr.sort() result = 0 if arr[0] == arr[1]: result = a..

Algorithm/SWEA

[SWEA - D3] 1230. ์•”ํ˜ธ๋ฌธ3

๋‚˜์˜ ์ฝ”๋“œ for t in range(1, 11): N = int(input()) # ์ฒซ ๋ฒˆ์งธ ์ค„ : ์›๋ณธ ์•”ํ˜ธ๋ฌธ์˜ ๊ธธ์ด N arr = list(map(int,input().split())) # ๋‘ ๋ฒˆ์งธ ์ค„ : ์›๋ณธ ์•”ํ˜ธ๋ฌธ cmd = int(input()) # ์„ธ ๋ฒˆ์งธ ์ค„ : ๋ช…๋ น์–ด์˜ ๊ฐœ์ˆ˜ cmd_arr = list(input().split()) # ๋„ค ๋ฒˆ์งธ ์ค„ : ๋ช…๋ น์–ด for i in range(len(cmd_arr)): if cmd_arr[i] == 'A' : cnt = int(cmd_arr[i+1]) for j in range(cnt): tmp = int(cmd_arr[i+2+j]) arr.append(tmp) if cmd_arr[i] == 'I': idx = int(cmd_arr[i+1]) cn..

Algorithm/SWEA

[SWEA - D3] 1213. String

์ฃผ์–ด์ง€๋Š” ๋ฌธ์ž์—ด์—์„œ ํŠน์ •ํ•œ ๋ฌธ์ž์—ด์˜ ๊ฐœ์ˆ˜๋ฅผ ๋ฐ˜ํ™˜ํ•˜๊ธฐ๊ธฐ Starteatingwellwiththeseeighttipsforhealthyeating,whichcoverthebasicsofahealthydietandgoodnutrition. ์œ„ ๋ฌธ์žฅ์—์„œ ti ๋ฅผ ๊ฒ€์ƒ‰ํ•˜๋ฉด, ๋‹ต์€ 4์ด๋‹ค. ๋‚˜์˜ ์ฝ”๋“œ for _ in range(1, 11): t = int(input()) s1 = input() s2 = input() s1L = len(s1) s2L = len(s2) cnt = 0 for i in range(s2L-s1L+1): if s2[i:s1L+i] == s1: cnt += 1 print("#"+str(t) , cnt ) ํŒŒ์ด์ฌ์—๋Š” count ํ•จ์ˆ˜๊ฐ€ ์žˆ๋‹ค. ์ƒ๊ฐ ์•ˆ๋‚˜์„œ ๋ฌธ์ž์—ด ์Šฌ๋ผ์ด์‹ฑํ•ด์„œ ๋ฐ˜๋ณต๋ฌธ๋Œ๋ฆฌ๊ณ  ๋น„๊ตํ•ด์„œ ..

Algorithm/SWEA

[SWEA - D3] 1225. ์•”ํ˜ธ์ƒ์„ฑ๊ธฐ

๋‚˜์˜ ์ฝ”๋“œ from collections import deque for _ in range(1, 11): t = int(input()) arr = list(map(int,input().split())) deq = deque(arr) while 0 not in deq: for i in range(1,6): tmp = deq.popleft() if tmp-i

Algorithm/SWEA

[SWEA - D3] 1216. ํšŒ๋ฌธ2

๊ฐ€์žฅ ๊ธด ํšŒ๋ฌธ์˜ ๊ธธ์ด๋ฅผ ๊ตฌํ•˜๋Š” ๋ฌธ์ œ ๋‚˜์˜ ์ฝ”๋“œ for _ in range(10): t = int(input()) arr = [] result = 0 for _ in range(100): arr.append(input()) for i in range(100): b = [x[i] for x in arr] for j in range(100): for length in range(1,101): if j+length > 100: break tmp1 = arr[i][j:j+length] tmp2 = b[j:j+length] if tmp1 == tmp1[::-1] and length > result: result = length if tmp2 == tmp2[::-1] and length > result: result..

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