Skip to content

Instantly share code, notes, and snippets.

@taichunmin
Created December 7, 2014 05:59
Show Gist options
  • Save taichunmin/2d813d8f74cd3b844fa7 to your computer and use it in GitHub Desktop.
Save taichunmin/2d813d8f74cd3b844fa7 to your computer and use it in GitHub Desktop.

Problem 3 (Python)

from sys import stdin
import collections

len1, len2 = [ int(_) for _ in stdin.readline().split(' ')]
len1 -= 1
ans, sum = 0, 0
arr1 = collections.deque([])

for t1 in range(len2):
    # print(ans, sum, arr1)
    arr1.append(int(stdin.readline()))
    sum += arr1[-1] - (arr1.popleft() if (t1 > len1) else 0)
    if sum > ans:
        ans = sum

print(ans)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment