Submission #1072563


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
t = 1
for a in A:
	if not a:
		t += 1
	else:
		t = 1
	if t >= 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 336 Byte
Status
Exec Time 136 ms
Memory 14480 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 23 ms 3192 KB
1_01.txt 22 ms 3064 KB
1_02.txt 22 ms 3064 KB
1_03.txt 53 ms 4908 KB
1_04.txt 90 ms 14152 KB
1_05.txt 72 ms 14124 KB
1_06.txt 85 ms 14176 KB
1_07.txt 83 ms 14044 KB
1_08.txt 85 ms 13912 KB
1_09.txt 94 ms 14220 KB
1_10.txt 99 ms 14048 KB
1_11.txt 113 ms 14384 KB
1_12.txt 99 ms 13948 KB
1_13.txt 114 ms 14136 KB
1_14.txt 98 ms 14036 KB
1_15.txt 109 ms 14300 KB
1_16.txt 126 ms 14220 KB
1_17.txt 136 ms 14480 KB
1_18.txt 107 ms 14080 KB
1_19.txt 107 ms 14076 KB
1_20.txt 108 ms 13880 KB
1_21.txt 105 ms 14256 KB