Skip to content

Instantly share code, notes, and snippets.

@IKKO-Ohta
Created July 15, 2017 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IKKO-Ohta/7ab10710fae23588434b94f03013e4bb to your computer and use it in GitHub Desktop.
Save IKKO-Ohta/7ab10710fae23588434b94f03013e4bb to your computer and use it in GitHub Desktop.
N = int(input())
S = [int(x) for x in input().split()]
ans = - 10000
def dfs(t,i=0):
if (t == 1):
res = []
for j in range(N):
if j > i: i,j = j,i
s = S[i:j]
takahashi = [s[i] for i in range(len(s)) if i % 2 == 0]
aoki = [s[i] for i in range(len(s)) if i % 2 == 1]
res.append((sum(takahashi),sum(aoki)))
res = sorted(res, key=lambda x: x[1])
return res[0]
for i in range(N):
p = dfs(t+1,i)
ans = max(ans,p[0])
return ans
if __name__ == '__main__':
ans = dfs(0,0)
print(ans)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment