Skip to content

Instantly share code, notes, and snippets.

@mym0404
Created June 14, 2022 06:28
Show Gist options
  • Save mym0404/6d925f32a92a5d3d81351179ad4cf3bb to your computer and use it in GitHub Desktop.
Save mym0404/6d925f32a92a5d3d81351179ad4cf3bb to your computer and use it in GitHub Desktop.
t = int(input())
while t:
t -= 1
answer = -10 ** 9
n = int(input())
a = list(map(int, input().split()))
psum = [0 for _ in range(n + 1)]
for i in range(n):
psum[i + 1] = psum[i] + a[i]
for l in range(n):
for r in range(l, n):
answer = max(answer, psum[r + 1] - psum[l])
print(answer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment