Skip to content

Instantly share code, notes, and snippets.

@jo32
Last active October 12, 2015 13:47
Show Gist options
  • Select an option

  • Save jo32/61bb5bdfddc50fbfa2fb to your computer and use it in GitHub Desktop.

Select an option

Save jo32/61bb5bdfddc50fbfa2fb to your computer and use it in GitHub Desktop.
CODEFORCE 327A
n = int(raw_input())
a = [int(i) for i in raw_input().split(' ')]
def flip(a, i, j):
for index in range(i, j + 1):
a[index] = 1 - a[index]
maxCount = -1
for i in range(n):
for j in range(i, n):
flip(a, i, j)
tempMax = sum(a)
flip(a, i, j)
maxCount = tempMax if tempMax > maxCount else maxCount
print maxCount
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment