๐Ÿค[์•Œ๊ณ ๋ฆฌ์ฆ˜] SW Expert ํŒŒ์ด์ฌ SW๋ฌธ์ œํ•ด๊ฒฐ ๊ธฐ๋ณธ - LIST1 ์•Œ๊ณ ๋ฆฌ์ฆ˜

์ „๊ธฐ๋ฒ„์Šค

 l=[int(x) for x in input().split()]
 
 l = list(map(int,input().split()))

์—ฌ๋Ÿฌ๊ฐœ ๋™์‹œ์— ์ž…๋ ฅ๋ฐ›์€ ์ •์ˆ˜ input์„ ๋ฆฌ์ŠคํŠธ๋กœ ๋งŒ๋“ค๋•Œ

print(list(l))

๋ฆฌ์ŠคํŠธ ์ถœ๋ ฅํ• ๋•Œ. print(l)ํ•˜๋ฉด ์ œ๋Œ€๋กœ ์ถœ๋ ฅ๋˜์ง€ ์•Š์Œ


์ˆซ์ž์นด๋“œ

count=[0 for i in range(10)]

๋ฆฌ์ŠคํŠธ ์ถ•์•ฝํ•ด์„œ ์ดˆ๊ธฐํ™”

a=b[:] #์Šฌ๋ผ์ด์‹ฑ์„ ์ด์šฉํ•œ ๋ฐฉ๋ฒ•

a=b.copy() #copy๋ฅผ ์ด์šฉํ•œ ๋ฐฉ๋ฒ•

๋ฆฌ์ŠคํŠธ ๋ณต์‚ฌ. a=b๋กœ ๋ณต์‚ฌํ•˜๊ฒŒ ๋˜๋ฉด ๋ณต์‚ฌ๊ฐ€ ์•„๋‹Œ ์ฐธ์กฐ๊ฐ€ ๋˜์–ด ์ˆ˜์ •๋„ ๋™์‹œ์— ์ผ์–ด๋‚จ.


๊ตฌ๊ฐ„ํ•ฉ

a_sum=0
most=0
t=int(input())
for i in range(t):
   n,m=map(int, input().split())
   a=list(map(int, input().split()))
   for p in range(n-m+1):
       for q in range(m):
           a_sum+=a[p+q]
       if p==0:
           least=a_sum
       elif a_sum<least:
           least=a_sum
       if a_sum>most:
           most=a_sum
       a_sum=0
   print('#%d %d'%(i+1, most-least))
   most=0 #์ด๊ฑฐ ์ดˆ๊ธฐํ™” ์•ˆํ•ด์„œ ํ•œ์‹œ๊ฐ„ ๊ณ ๋ฏผํ•จ..

์ œ๋ฐœ for๋ฌธ ์žฌ์‚ฌ์šฉํ• ๋•Œ๋Š” ๋ณ€์ˆ˜ ์ดˆ๊ธฐํ™” ์ž˜ํ•˜๊ธฐ..

์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ