Last active
October 12, 2015 13:47
-
-
Save jo32/61bb5bdfddc50fbfa2fb to your computer and use it in GitHub Desktop.
CODEFORCE 327A
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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