Language: C

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def make4(initial, L, M, N, O):
    return [[[[initial for i in range(O)]
                for n in range(N)]
                for m in range(M)]
                for l in range(L)]


def make3(initial, L, M, N):
    return [[[initial for n in range(N)]
                for m in range(M)]
                for l in range(L)]


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N = I()
    A = LI()
    dp_use = [-IINF] * 5
    dp_not_use = [-IINF] * 5
    dp_not_use[0] = 0

    for k in range(N):
        dp_use_next = [-IINF] * 5
        dp_not_use_next = [-IINF] * 5
        for j in range(-3, 2):
            if j > -3:
                dp_use_next[j] = dp_not_use[j-1] + A[k]
            if j < 1:
                dp_not_use_next[j] = max(dp_use[j+1], dp_not_use[j+1])
        dp_use = dp_use_next
        dp_not_use = dp_not_use_next

    dif = N//2 - (N-N//2)
    print(max(dp_use[dif], dp_not_use[dif]))

    # print('===============================')
    # dp = [[-IINF] * (N//2+1) for i in range(N)]
    # dp[0][1] = A[0]

    # for i in range(N):
    #     for j in range(1, N//2+1):
    #         if i - 4 >= 0 and j - 1 > 0:
    #             dp[i][j] = max(dp[i][j], A[i] + max(dp[i-4][j-1], dp[i-3][j-1], dp[i-2][j-1]))
    #         if i - 3 >= 0 and j - 1 > 0:
    #             dp[i][j] = max(dp[i][j], A[i] + max(dp[i-3][j-1], dp[i-2][j-1]))
    #         if i - 2 >= 0 and j - 1 > 0:
    #             dp[i][j] = max(dp[i][j], A[i] + dp[i-2][j-1])
    #             # print(dp[i])
    #             # print(i, j, A[i])
    #             # return
    #         if i <= 2 and j == 1:
    #             dp[i][j] = A[i]
    #     print(dp[i])


if __name__ == '__main__':
    main()


Compiler output:
main.c:1:1: error: unknown type name 'from'
    1 | from heapq import heappush, heappop, heapify
      | ^~~~
main.c:1:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'import'
    1 | from heapq import heappush, heappop, heapify
      |            ^~~~~~
main.c:1:12: error: unknown type name 'import'
main.c:56:24: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
   56 |             ret.append('{}: {}'.format(name, val))
      |                        ^~~~~~~~
main.c:57:11: warning: multi-character character constant [-Wmultichar]
   57 |     print(' | '.join(ret), file=sys.stderr)
      |           ^~~~~
main.c:60:14: warning: multi-character character constant [-Wmultichar]
   60 | yn = {False: 'No', True: 'Yes'}
      |              ^~~~
main.c:60:26: warning: multi-character character constant [-Wmultichar]
   60 | yn = {False: 'No', True: 'Yes'}
      |                          ^~~~~
main.c:61:1: warning: data definition has no type or storage class
   61 | YN = {False: 'NO', True: 'YES'}
      | ^~
main.c:61:1: error: type defaults to 'int' in declaration of 'YN' [-Wimplicit-int]
main.c:61:7: error: field name not in record or union initializer
   61 | YN = {False: 'NO', True: 'YES'}
      |       ^~~~~
main.c:61:7: note: (near initialization for 'YN')
main.c:61:14: warning: multi-character character constant [-Wmultichar]
   61 | YN = {False: 'NO', True: 'YES'}
      |              ^~~~
main.c:61:20: error: field name not in record or union initializer
   61 | YN = {False: 'NO', True: 'YES'}
      |                    ^~~~
main.c:61:20: note: (near initialization for 'YN')
main.c:61:26: warning: multi-character character constant [-Wmultichar]
   61 | YN = {False: 'NO', True: 'YES'}
      |                          ^~~~~
main.c:61:26: warning: excess elements in scalar initializer
main.c:61:26: note: (near initialization for 'YN')
main.c:62:1: error: expected ',' or ';' before 'MOD'
   62 | MOD = 10**9+7
      | ^~~
main.c:63:13: warning: multi-character character constant [-Wmultichar]
   63 | inf = float('inf')
      |             ^~~~~
main.c:69:54: warning: multi-character character constant [-Wmultichar]
   69 | nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
      |                                                      ^~~~
main.c:72:3: error: invalid preprocessing directive #show_flg
   72 | # show_flg = True
      |   ^~~~~~~~
main.c:96:7: error: invalid preprocessing directive #print
   96 |     # print('===============================')
      |       ^~~~~
main.c:97:7: error: invalid preprocessing directive #dp
   97 |     # dp = [[-IINF] * (N//2+1) for i in range(N)]
      |       ^~
main.c:98:7: error: invalid preprocessing directive #dp
   98 |     # dp[0][1] = A[0]
      |       ^~
main.c:100:7: error: invalid preprocessing directive #for
  100 |     # for i in range(N):
      |       ^~~
main.c:101:11: error: invalid preprocessing directive #for
  101 |     #     for j in range(1, N//2+1):
      |           ^~~
main.c:102:29: error: missing binary operator before token "and"
  102 |     #         if i - 4 >= 0 and j - 1 > 0:
      |                             ^~~
main.c:111: error: unterminated #if
  111 |     #         if i <= 2 and j == 1:
main.c:106: error: unterminated #if
  106 |     #         if i - 2 >= 0 and j - 1 > 0:
main.c:104: error: unterminated #if
  104 |     #         if i - 3 >= 0 and j - 1 > 0:
main.c:102: error: unterminated #if
  102 |     #         if i - 4 >= 0 and j - 1 > 0: