import sys
test_cases = open(sys.argv[1], 'r')
for test in test_cases:
arr=test.split(";")
valz=map(int,arr[1].split(" "))
sum=0
for i in range(int(arr[0])):
sum = sum + valz[i]
max=sum
if max<0:
max=0
for i in range(int(arr[0]),len(valz)):
sum = sum + valz[i]
sum = sum - valz[i-int(arr[0])]
if (max<sum):
max=sum
print max
test_cases.close()
test_cases = open(sys.argv[1], 'r')
for test in test_cases:
arr=test.split(";")
valz=map(int,arr[1].split(" "))
sum=0
for i in range(int(arr[0])):
sum = sum + valz[i]
max=sum
if max<0:
max=0
for i in range(int(arr[0]),len(valz)):
sum = sum + valz[i]
sum = sum - valz[i-int(arr[0])]
if (max<sum):
max=sum
print max
test_cases.close()
No comments:
Post a Comment