Submission #1072566


Source Code Expand

Copy
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
ans = 0
for i in range(N):
	if A[i] > 0:
		ans += A[i]
		A[i] = 0
s = 0
t = 0
for a in A:
	if not a:
		t += 1
		s = 1
	else:
		t = 1
		s += 1
	if t >= K or s >= K:
		print(ans)
		exit()
m = sum(A[:K])
for i in range(N-K):
	M = m - A[i] + A[i+K]
	m = max(M,m)
print(max(ans+m,0))

Submission Info

Submission Time
Task B - Contiguous Repainting
User TAB
Language Python3 (3.4.3)
Score 0
Code Size 372 Byte
Status
Exec Time 144 ms
Memory 14256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
All 0 / 400 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt
Case Name Status Exec Time Memory
0_00.txt 22 ms 3064 KB
0_01.txt 22 ms 3064 KB
0_02.txt 22 ms 3064 KB
0_03.txt 22 ms 3064 KB
1_00.txt 22 ms 3064 KB
1_01.txt 22 ms 3064 KB
1_02.txt 22 ms 3064 KB
1_03.txt 52 ms 5036 KB
1_04.txt 90 ms 14152 KB
1_05.txt 70 ms 14124 KB
1_06.txt 87 ms 14176 KB
1_07.txt 82 ms 13912 KB
1_08.txt 94 ms 13912 KB
1_09.txt 102 ms 14220 KB
1_10.txt 107 ms 14048 KB
1_11.txt 116 ms 14000 KB
1_12.txt 109 ms 14084 KB
1_13.txt 122 ms 14008 KB
1_14.txt 108 ms 14116 KB
1_15.txt 120 ms 14020 KB
1_16.txt 140 ms 14128 KB
1_17.txt 144 ms 14096 KB
1_18.txt 116 ms 14212 KB
1_19.txt 118 ms 14008 KB
1_20.txt 119 ms 13880 KB
1_21.txt 113 ms 14256 KB