Skip to content

Instantly share code, notes, and snippets.

@maehrm
Created April 5, 2026 07:13
Show Gist options
  • Select an option

  • Save maehrm/67df03eca20455c8207cd41c8a5ba24f to your computer and use it in GitHub Desktop.

Select an option

Save maehrm/67df03eca20455c8207cd41c8a5ba24f to your computer and use it in GitHub Desktop.
N = int(input())
a = list(map(int, input().split()))
takahashi_best_score = -float("inf")
for i in range(N): # 高橋君がiを選んだ
aoki_score = -float("inf")
aoki_j = None
for j in range(N): # 青木君がjを選んだ
if i == j:
continue
left = min(i, j)
right = max(i, j)
T = a[left : right + 1]
ac = sum(T[1::2]) # このjでの青木君のスコア as だと予約後になるので、ac
if ac > aoki_score:
aoki_score = ac
aoki_j = j
takahashi_best_score = max(takahashi_best_score, sum(a[min(i, aoki_j) : max(i, aoki_j) + 1 : 2]))
print(takahashi_best_score)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment