Problem:


Score : 600 points

Problem Statement

There is an infinitely large pond, which we consider as a number line.
In this pond, there are N lotuses floating at coordinates 0, 1, 2, ..., N-2 and N-1.
On the lotus at coordinate i, an integer s_i is written.

You are standing on the lotus at coordinate 0. You will play a game that proceeds as follows:

1. Choose positive integers A and B. Your score is initially 0.

2. Let x be your current coordinate, and y = x+A. The lotus at coordinate x disappears, and you move to coordinate y.

If y = N-1, the game ends.

If y \neq N-1 and there is a lotus floating at coordinate y, your score increases by s_y.

If y \neq N-1 and there is no lotus floating at coordinate y, you drown. Your score decreases by 10^{100} points, and the game ends.

3. Let x be your current coordinate, and y = x-B. The lotus at coordinate x disappears, and you move to coordinate y.

If y = N-1, the game ends.

If y \neq N-1 and there is a lotus floating at coordinate y, your score increases by s_y.

If y \neq N-1 and there is no lotus floating at coordinate y, you drown. Your score decreases by 10^{100} points, and the game ends.

4. Go back to step 2.

You want to end the game with as high a score as possible.
What is the score obtained by the optimal choice of A and B?

Constraints

3 \leq N \leq 10^5

-10^9 \leq s_i \leq 10^9

s_0=s_{N-1}=0

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
s_0 s_1 ...... s_{N-1}

Output

Print the score obtained by the optimal choice of A and B.

Sample Input 1

5
0 2 5 1 0

Sample Output 1

3

If you choose A = 3 and B = 2, the game proceeds as follows:

Move to coordinate 0 + 3 = 3. Your score increases by s_3 = 1.

Move to coordinate 3 - 2 = 1. Your score increases by s_1 = 2.

Move to coordinate 1 + 3 = 4. The game ends with a score of 3.

There is no way to end the game with a score of 4 or higher, so the answer is 3. Note that you cannot land the lotus at coordinate 2 without drowning later.

Sample Input 2

6
0 10 -7 -4 -13 0

Sample Output 2

0

The optimal strategy here is to land the final lotus immediately by choosing A = 5 (the value of B does not matter).

Sample Input 3

11
0 -4 0 -99 31 14 -15 -39 43 18 0

Sample Output 3

59



Sample input:
5
0 2 5 1 0


Sample output:
3

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    M = N//2
    S = list(map(int, input().split()))
    R = [0] * M
    for i in range(M):
        R[i] = S[i] + S[N-i-1]
    ans = 0
    for step in range(1, M):
        total = 0
        for i in range(0, M, step):
            total += R[i]
            ans = max(ans, total)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
s=[int(i) for i in input().split()]
ans=0
for c in range(1,N):
  k=0
  Score=0
  while k*c<N-1:
    a=N-1-k*c
    if (N-1)%c==0 and k*c>=a:
      break
    Score+=s[k*c]+s[a]
    #print(c,k,Score)
    ans=max(Score,ans)
    k+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n,*s=map(int,open(0).read().split())
i = 1
ans = 0
while(i < n):
  tmp = 0
  j = 1
  if((n - 1)%i != 0):
    while(j < n):
      if(n - 1 - i*j - i <= 0):
        break
      tmp += s[i*j] + s[~(i*j)]
      j += 1
  else:
    while(n - 1 - 2*i*j > 0):
      tmp += s[i*j] + s[~(i*j)]
      j += 1
  ans = max(ans, tmp)
  i += 1
  
print(ans)

Submission status: Wrong Answer

Solution code:
n,*s=map(int,open(0).read().split())
i = 1
ans = 0
while(i < n):
  tmp = 0
  if((n - 1)%i != 0):
    for j in range(n):
      if(n - 1 - i*j <= 0):
        break
      tmp += s[i*j] + s[~(i*j)]
  else:
    j = 0
    while(n - 1 - 2*i*j > 0):
      tmp += s[i*j] + s[~(i*j)]
      j += 1
  ans = max(ans, tmp)
  i += 1
  
print(ans)

Submission status: Wrong Answer

Solution code:
n,*s=map(int,open(0).read().split());a=0
i = 1
ans = 0
while(i < n):
  tmp = 0
  if((n - 1)%i != 0):
    for j in range(n):
      if(n - 1 - i*j <= 0):
        break
      tmp += s[i*j] + s[~(i*j)]
      ans = max(ans, tmp)
  i += 1
  
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
mp = list(map(int, input().split()))


def check(a, b):
    if (n - b - 1) % (a - b) != 0:
        return False
    if a % (a - b) == 0 and (a + b) >= n - 1:
        return True
    return False


ans = 0
if n == 3:
    print(0)
else:
    for a in range(2, n):
        for b in range(1, a):
            if check(a, b):
                continue
            else:
                ans = max(ans, 0)
    print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
da=list(map(int,input().split()))
ans=0
for i in range(2,n):
    if (n-1)%i==0 and i!=n-1:
        continue
    su=0
    for j in range(0,n,i):
        su+=da[j]
    for j in range(n-1,-1,-i):
        su+=da[j]
    ans=max(ans,su)
print(ans)

Submission status: Wrong Answer

Solution code:
def inpl(): return list(map(int, input().split()))
N = int(input())
S = inpl()

ans = S[-1]*1
for C in range(1, N-1):
    tmp = S[-1]*1
    div, mod = divmod(N-1, C)
    if mod == 0:
        X = (div-1)//2
    else:
        X = -(-(N-1)//(2*C))
    for c in range(C, (X+1)*C, C):
        if N-1-c - C < 0:
            break
        if N-1-c <= c:
            break
        tmp += S[N-1-c] + S[c]
        ans = max(ans, tmp)

print(ans)

Submission status: Wrong Answer

Solution code:
def inpl(): return list(map(int, input().split()))
N = int(input())
S = inpl()

ans = S[-1]
for C in range(1, N-1):
    tmp = S[-1]
    div, mod = divmod(N-1, C)
    if mod == 0:
        X = (div-1)//2
    else:
        X = -(-(N-1)//(2*C))
    for c in range(C, (X+1)*C, C):
        if N-1-c - C < 0:
            break
        if N-1-c > c:
            break
        tmp += S[N-1-c] + S[c]
        ans = max(ans, tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(int(1e7))
#input = sys.stdin.readline

def inpl(): return list(map(int, input().split()))
N = int(input())
S = inpl()

ans = S[-1]
for C in range(1, N-1):
    tmp = S[-1]
    div, mod = divmod(N-1, C)
    if mod == 0:
        X = (div-1)//2
    else:
        X = -(-(N-1)//(2*C))
    for c in range(C, (X+1)*C, C):
        tmp += S[N-1-c] + S[c]
        ans = max(ans, tmp)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(int(1e7))
#input = sys.stdin.readline

def inpl(): return list(map(int, input().split()))
N = int(input())
S = inpl()

ans = S[-1]
for c in range(1, N-1):
    searched = [0]*(N)
    tmp = S[-1]
    searched[-1] = True
    i = 1
    C = c
    A = N - 1 - c
    while A > c and not (searched[A]|searched[C]|(A==C)|(A-C<=0)) :
        tmp += S[A] + S[C]
        ans = max(tmp, ans)
        searched[A] = 1
        searched[C] = 1
        A -= c
        C += c
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int,input().split()))
from collections import defaultdict

ans = 0
for C in range(1,N-1):
    dp = [0]*N
    for k in range(N-1):
        if (2*k+1)*C == N-1 or 2*(k+1)*C == N-1 or C*(k+1) >= N-1:
            break
        dp[k+1] = dp[k]+S[N-1-C*(k+1)]+S[C*(k+1)]
        ans = max(ans,dp[k+1])

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int,input().split()))
from collections import defaultdict
dp = defaultdict(lambda:[0]*N)
ans = 0
for C in range(1,N-1):
    for k in range(N-1):
        if (2*k+1)*C == N-1 or 2*(k+1)*C == N-1 or C*(k+1) >= N-1:
            break
        dp[C][k+1] = dp[C][k]+S[N-1-C*(k+1)]+S[C*(k+1)]
        ans = max(ans,dp[C][k+1])

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int,input().split()))
from collections import defaultdict
dp = defaultdict(lambda:[0]*N)
path = [[0]*N for i in range(N)]
ans = 0
for C in range(1,N-1):
    k = 0
    while C*(k+1) < N-1 and path[C][N-1-C*(k+1)] == 0 and path[C][C*(k+1)] == 0 and N-1-C*(k+1) != C*(k+1):
        path[C][N-1-C*(k+1)] = 1
        path[C][C*(k+1)] = 1    
        dp[C][k+1] = dp[C][k]+S[N-1-C*(k+1)]+S[C*(k+1)]
        ans = max(ans,dp[C][k+1])
        k += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int,input().split()))
from collections import defaultdict
dp = defaultdict(lambda:[0]*N)
path = [defaultdict(lambda:0) for i in range(N)]
ans = 0
for C in range(1,N-1):
    k = 0
    path[C][0] = 1
    while C*(k+1) < N-1:
        if path[C][N-1-C*(k+1)] == 1:
            break
        else:
            path[C][N-1-C*(k+1)] = 1
        if path[C][C*(k+1)] == 1:
            break
        else:
            path[C][C*(k+1)] = 1
            
        dp[C][k+1] = dp[C][k]+S[N-1-C*(k+1)]+S[C*(k+1)]
        ans = max(ans,dp[C][k+1])
        k += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int,input().split()))
from collections import defaultdict
dp = defaultdict(lambda:[0]*N)
path = [defaultdict(lambda:0) for i in range(N)]
for C in range(1,N-1):
    k = 0
    path[C][0] = 1
    while C*(k+1) < N-1:
        if path[C][N-1-C*(k+1)] == 1:
            break
        else:
            path[C][N-1-C*(k+1)] = 1
        if path[C][C*(k+1)] == 1:
            break
        else:
            path[C][C*(k+1)] = 1
            
        dp[C][k+1] = dp[C][k]+S[N-1-C*(k+1)]+S[C*(k+1)]
        k += 1
ans = 0
for C in range(1,N-1):
    ans = max(ans,max(dp[C]))
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int( input())
S = list( map( int, input().split()))

ans = 0
for c in range(1,N):
    now = 0
    for t in range(c ,N, c):
        if ((N-1-t)%c == 0 and N-1-t <= t):
            break
        now += S[t] + S[N-1-t]
        if now > ans:
            ans = now
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int( input())
S = list( map( int, input().split()))

ans = 0
for c in range(1,N):
    now = 0
    for t in range(c ,N, c):
        if ((N-1-t)%c == 0 and N-1-t <= t):
            break
        now += S[t] + S[N-1-t]
        print(now, t)
        if now > ans:
            ans = now
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int( input())
S = list( map( int, input().split()))

ans = 0
for c in range(1,N):
    now = 0
    k = 1
    for _ in range(1,N):
        if k*2 + 1 > N-2:
            break
        if k*c >= N-1:
            break
        if (N-1-k*c)%c <= k:
            break
        now += S[k*c] + S[N-1-k*c]
        if now > ans:
            ans = now
        k += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int( input())
S = list( map( int, input().split()))

ans = 0
for c in range(1,N):
    now = 0
    k = 1
    d = defaultdict( int)
    d[0] = 1
    d[N-1] = 1
    for _ in range(1,N):
        if k*2 + 1 > N-2:
            break
        if k*c >= N-1:
            break
        if d[k*c] == 1 or d[N-1-k*c] == 1:
            break
        now += S[k*c] + S[N-1-k*c]
        d[k*c] = 1
        d[N-1-k*c] = 1
        if now > ans:
            ans = now
        k += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque
N = int( input())
S = list( map( int, input().split()))

ans = 0
for c in range(1,N):
    now = 0
    k = 1
    for _ in range(1,N):
        if k*2 + 1 > N-2:
            break
        if k*c >= N-1:
            break
        if k*c >= N-1-k*c:
            break
        now += S[k*c] + S[N-1-k*c]
        if now > ans:
            ans = now
        k += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque
N = int( input())
S = list( map( int, input().split()))

ANS = [ deque() for _ in range(N-1)]
ans = 0
for c in range(1,N):
    now = 0
    H = [0]*N
    H[0] = 1
    H[-1] = 1
    k = 1
    for _ in range(1,N):
        if k*2 + 1 > N-2:
            break
        if k*c >= N-1:
            break
        if H[k*c] == 1 or H[N-1-k*c] == 1 or k*c == N-1-k*c:
            break
        now += S[k*c] + S[N-1-k*c]
        H[k*c] = 1
        H[N-1-k*c] = 1
        if now > ans:
            ans = now
        k += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = [int(i) for i in input().split()]

ret = 0
for c in range(1, N) :
    k = 1
    tmp = 0
    flag = (N - 1) % c == 0
    while c * k < N - 1 :
        l = c * k
        r = N - 1 - l

        if flag and l >= r :
            break

        tmp += s[l] + s[r]
        ret = max(ret, tmp)
        k += 1

print(ret)

Submission status: Wrong Answer

Solution code:
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    S = list(map(int, input().split()))

    ans = 0
    for C in range(1, N//2):
        n = N // C
        point = 0
        for k in range(1, n):
            A = N - 1 - k*C
            if A < C or ((N-1) % C == 0 and A < k*C):
                break

            point += S[A] + S[k*C]
            ans = max(ans, point)

    return ans


if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N = II()
    S = LI()
    ans = 0
    for C in range(1, N):
        tmp = 0
        L = 0
        R = N - 1
        lim = (N - 1 - C) if (N - 1) % C else (N - 1) // 2
        while L < lim:
            tmp += S[L] + S[R]
            ans = max(ans, tmp)
            L += C
            R -= C
    return ans

print(main())

Submission status: Wrong Answer

Solution code:
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    S = list(map(int, input().split()))

    ans = 0
    for C in range(1, N//2):
        n = N // C
        point = 0
        for k in range(1, n):
            A = N - 1 - k*C
            if A <= k*C:
                break

            point += S[A] + S[k*C]
            ans = max(ans, point)

    return ans


if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N = II()
    S = LI()
    ans = 0
    for C in range(1, N):
        tmp = 0
        lim = (N - 1) if (N - 1) % C else (N - 1) // 2
        for kC in range(C, lim, C):
            A = (N - 1) - kC
            if C >= A:
                break
            tmp += S[kC] + S[N - 1 - kC]
            ans = max(ans, tmp)
    return ans

print(main())

Submission status: Wrong Answer

Solution code:
from numpy import*
n,*s=map(int,open(0).read().split())
s=array(s)
ans=[]
for a in range(2,n//2+2):
    for b in range(a):
        tmp=(n-1-a)/(a-b)
        if int(tmp)==tmp:
#            print(tmp,a,b)
            tmp=[]
            i=0
            for _ in range(2*n):
                i+=a
                tmp.append(i)
                if i>=n-1:
                    break
                i-=b
                if i in tmp:
                    tmp=[0]
                    break
                tmp.append(i)
            ans.append(sum(s[array(tmp)]))
print(max(ans))

Submission status: Wrong Answer

Solution code:
from numpy import*
n,*s=map(int,open(0).read().split())
s=array(s)
ans=[]
for a in range(2,n//2+2):
    for b in range(a):
        tmp=(n-1-a)/(a-b)
        if int(tmp)==tmp:
            print(tmp,a,b)
            tmp=[]
            i=0
            for _ in range(2*n):
                i+=a
                tmp.append(i)
                if i>=n-1:
                    break
                i-=b
                if i in tmp:
                    tmp=[0]
                    break
                tmp.append(i)
            ans.append(sum(s[array(tmp)]))
print(max(ans))

Submission status: Wrong Answer

Solution code:
def main():
	import sys
	inputs = sys.stdin.readline
	N = int(inputs())
	S = tuple(map(int,inputs().split()))
	C = []
	for a in range(2,N):
		if N%a == 0:
			continue
		for b in range(1,a):
			C.append((a,b))
	C =tuple(C)
	ans = 0
	wa = 0
	leaf = 0
	leaves = {0}
	for c in C:
		leaves = {0}
		leaf = 0
		while(True):
			leaf += c[0]
			leaves.add(leaf)
			if leaf == N-1:
				for l in leaves:
					wa += S[l]
				ans = max(wa,ans)
				wa = 0
				break
			elif leaf > N-1:
				break
			leaf -= c[1]
			if {leaf} & leaves:
				break
			else:
				leaves.add(leaf)
	print(ans)
main()

Submission status: Wrong Answer

Solution code:
def main():
	import sys
	inputs = sys.stdin.readline
	N = int(inputs())
	S = tuple(map(int,inputs().split()))
	C = []
	for a in range(2,N-1):
		if N%a == 0:
			continue
		for b in range(1,a):
			C.append((a,b))
	C =tuple(C)
	ans = 0
	wa = 0
	leaf = 0
	leaves = {0}
	for c in C:
		while(True):
			leaf += c[0]
			leaves.add(leaf)
			if leaf == N-1:
				for l in leaves:
					wa += S[l]
				ans = max(wa,ans)
				wa = 0
				leaves = {0}
				leaf = 0
				break
			elif leaf > N-1:
				leaves = {0}
				leaf = 0
				break
			leaf -= c[1]
			if {leaf} & leaves:
				leaves = {0}
				leaf = 0
				break
			else:
				leaves.add(leaf)
	print(ans)
main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

def solve(N: int, S: "List[int]"):
    ans = 0
    for D in range(1,N):
        if (N-1)%D==0:
            continue
        L,R=(D,N-1-D)
        total = 0
        while L<N and R>=0:
            total += S[L]+S[R]
            L+=D
            R-=D
        ans = max(ans, total)
    print(ans)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [ int(next(tokens)) for _ in range(N-1-0+1) ]  # type: "List[int]"
    solve(N, s)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

def solve(N: int, S: "List[int]"):
    ans = S[0]+S[-1]
    for D in range(1,N):
        R = (N-1)%D
        if R>0:
            ans = max(ans, sum(S[::D])+sum(S[R:][::D]))
    print(ans)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [ int(next(tokens)) for _ in range(N-1-0+1) ]  # type: "List[int]"
    solve(N, s)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

def solve(N: int, S: "List[int]"):
    ans = 0
    for D in range(1,N):
        R = (N-1)%D
        if R>0:
            ans = max(ans, sum(S[::D])+sum(S[R:][::D]))
    print(ans)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [ int(next(tokens)) for _ in range(N-1-0+1) ]  # type: "List[int]"
    solve(N, s)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
S = np.array([int(x) for x in input().split()])

# 右移動着地点：等差数列、ゴール含む
# 左移動着地点：等差数列、スタート含む

answer = 0
for d in range(1,N+1):
    # d = A-B
    cum_left = np.cumsum(S[::d])
    cum_right = np.cumsum(S[::-1][::d])
    score = cum_left + cum_right # 等差数列の長さ -> 得点
    # あとは、その経路がルール内で実現できるかどうか
    for L,s in enumerate(score):
        if answer >= s:
            continue
        # 右左に進んでいることの確認
        A = N-1-L*d
        B = A-d
        if A<=B:
            continue
        # 同じ場所を取っていないかの確認
        # kd = N-1-ldとなるとまずい
        # 約数のとき、Ld >= N-Ldだとまずい
        if (N-1)%d == 0 and 2*L*d >= N-1:
            continue
        answer = s


print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
S = np.array([int(x) for x in input().split()],dtype=np.int64)

# 右移動着地点：等差数列、ゴール含む
# 左移動着地点：等差数列、スタート含む

answer = 0
for d in range(1,N):
    # d = A-B
    cum_left = np.cumsum(S[::d])
    cum_right = np.cumsum(S[::-1][::d])
    score = cum_left + cum_right # 等差数列の長さ -> 得点
    # あとは、その経路がルール内で実現できるかどうか
    for L,s in enumerate(score):
        if answer >= s:
            continue
        # 右左に進んでいることの確認
        A = N-1-L*d
        B = A-d
        if A<=B:
            continue
        # 同じ場所を取っていないかの確認
        # kd = N-1-ldとなるとまずい
        # 約数のとき、Ld >= N-Ldだとまずい
        if (N-1)%d == 0 and 2*L*d >= N-1:
            continue
        answer = s


print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
S = np.array([int(x) for x in input().split()])

# 右移動着地点：等差数列、ゴール含む
# 左移動着地点：等差数列、スタート含む

answer = 0
for d in range(1,N):
    # d = A-B
    cum_left = np.cumsum(S[::d])
    cum_right = np.cumsum(S[::-1][::d])
    score = cum_left + cum_right # 等差数列の長さ -> 得点
    # あとは、その経路がルール内で実現できるかどうか
    for L,s in enumerate(score):
        if answer >= s:
            continue
        # 右左に進んでいることの確認
        A = N-1-L*d
        B = A-d
        if A<=B:
            continue
        # 同じ場所を取っていないかの確認
        # kd = N-1-ldとなるとまずい
        # 約数のとき、Ld >= N-Ldだとまずい
        if (N-1)%d == 0 and 2*L*d >= N-1:
            continue
        answer = s


print(answer)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int, input().split()))

ans = s[n-1]

def f(k, c):
    p = [0] * n
    a = n-1-k*c
    b = a - c
    #print(k, c, a, b)
    temp = 0
    while 0 <= temp <= n-1:
        if p[temp] == 1:
            return -1
        p[temp] = 1
        temp += a
        if p[temp] == 1:
            return -1
        p[temp] = 1
        if temp > n-1:
            return -1
        elif temp == n-1:
            return 0
        temp -= b
    return -1

for c in range(1, n-1):
    dp = s[n-1]
    for k in range(n-1):
        if k * c >= n-1:
            break
        else:
            dp += s[n - 1 - k * c] + s[k * c]
            if dp > ans:
                #print(k, c, dp, ans, 'dp')
                if f(k, c) == 0:
                    ans = dp

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
s=[int(i) for i in input().split()]
ans=0
for C in range(1,N-1):
    fkC=0
    k=0
    while((N-1-2*k*C)>0):
        fkC+=s[N-1-k*C]+s[k*C]
        ans=max(ans,fkC)
        k+=1
    if k==1:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
s=[int(i) for i in input().split()]
ans=0
for C in range(1,N-1):
    fkC=0
    k=0
    while((N-1-2*k*C)>0):
        fkC+=s[N-1-k*C]+s[k*C]
        print(C,k,fkC)
        ans=max(ans,fkC)
        k+=1
    if k==1:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
s=[int(i) for i in input().split()]
ans=0
for C in range(1,N-1):
    fkC=0
    k=0
    while(N-1-k*C>k*C):
        fkC+=s[N-1-k*C]+s[k*C]
        ans=max(ans,fkC)
        k+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def single_input(F): return F.readline().strip("\n")
def line_input(F): return F.readline().strip("\n").split()
  
def solve():
    F = sys.stdin
    N = int(single_input(F))
    S = [int(s) for s in line_input(F)]
    
    maxpoint = 0
    for c in range(1, N//2):
        s, l = 0, N-1
        point = 0
        if N % c > 0:
            while l > s and l > c:
                point += S[s] + S[l]
                maxpoint = max(point, maxpoint)
                s += c
                l -= c
        else:
            while l != s and l > c:
                point += S[s] + S[l]
                maxpoint = max(point, maxpoint)
                s += c
                l -= c
    print(maxpoint)
    return 0
  
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int, input().split()))

ans = 0
for c in range(1, N):
    a = 0
    if (N-1) % c:
        for i in range(1, (N-1)//c):
            a += S[i*c] + S[N-1-i*c]
            ans = max(ans, a)
    else:
        for i in range(1, 1+(N-1)//(2*c)):
            a += S[i*c] + S[N-1-i*c]
            ans = max(ans, a)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int, input().split()))

ans = 0
for c in range(1, N):
    a = 0
    if (N-1) % c:
        for i in range(1, 1+(N-1)//c):
            a += S[i*c] + S[N-1-i*c]
            ans = max(ans, a)
    else:
        for i in range(1, 1+(N-1)//(2*c)):
            a += S[i*c] + S[N-1-i*c]
            ans = max(ans, a)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int, input().split()))

ans = 0
for c in range(1, N):
    a = 0
    if (N-1) % c:
        for i in range(1, (N-1)//c):
            a += S[i*c] + S[N-1-i*c]
            ans = max(ans, a)
    else:
        for i in range(1, (N-1)//(2*c)):
            a += S[i*c] + S[N-1-i*c]
            ans = max(ans, a)
print(ans)

Submission status: Wrong Answer

Solution code:
from bisect import bisect, bisect_left
from math import sqrt
from collections import Counter, defaultdict
from functools import reduce
from itertools import accumulate, product
from operator import itemgetter, xor, mul

import sys
#input = sys.stdin.readline

def inpl(): return list(map(int, input().split()))

N = int(input())
S = inpl()

def primes(N):
    sieve = [1]*(N+1)
    sieve[:2] = [0, 0]
    P = []
    for i in range(2, N+1):
        if sieve[i]:
            P.append(i)
            for j in range(2*i, N+1, i):
                sieve[j] = 0
    return P


def get_factors(X):
    res = defaultdict(int)
    for i in range(bisect(P, sqrt(X))):
        while True:
            d, m = divmod(X, P[i])
            if m:
                break
            res[P[i]] += 1
            X = d
    if X != 1:
        res[X] += 1
    return res


def get_divisors(X):
    factors = get_factors(X)
    keys = sorted(factors.keys())
    iters = [[k**v for v in range(factors[k]+1)] for k in keys]
    return sorted([reduce(mul, I) for I in product(*iters)])


def get_divisors2(X):
    res = []
    res2 = []
    for f in range(1, int(sqrt(X))+1):
        d, m = divmod(X, f)
        if m == 0:
            res.append(f)
            res2.append(d)
    if res[-1] != res2[-1]:
        return res + res2[::-1]
    else:
        return res + res2[len(res2)-2::-1]

P = primes(10**3)

ans = -10**100
for b in range(1, N-1):
    X = N - 1 + b
    divisors = get_divisors(X)
    for d in divisors:
        a = d + b
        if a > N-1:
            continue
        div, m = divmod(b, a-b)
        if m == 0:
            if (a-b)*(div+1) + b < N-1:
                continue
        x = (N-1-b)//(a-b)
        ans = max(ans, sum(S[a::a-b]) + sum(S[a-b:(a-b)*x:a-b]))

print(ans)

Submission status: Wrong Answer

Solution code:
n,*s=map(int,open(0).read().split())
m=0
for i in range(1,n):
    t=0
    for j in range(0,n,i):
        k=n-1-j
        if k%i<1 and k<=j:break
        t+=s[j]+s[k]
        if t>m:m=t
print(m)

Submission status: Wrong Answer

Solution code:
n,*s=map(int,open(0).read().split())
m=0
for i in range(1,n):
    t=0
    for j in range(0,n,i):
        k=n-1-j
        if j==k or k%i<1 and k<=j:break
        t+=s[j]+s[k]
        if t>m:m=t
print(m)

Submission status: Wrong Answer

Solution code:
n,*s=map(int,open(0).read().split())
m=0
for i in range(1,n):
    t=0
    for j in range(0,n-1,i):
        k=n-1-j
        if j==k or k%i<1:break
        t+=s[j]+s[k]
        if t>m:m=t
print(m)

Submission status: Wrong Answer

Solution code:
n,*s=map(int,open(0).read().split())
m=0
for i in range(1,n):
    t=0
    f=[0]*n
    for j in range(0,n-1,i):
        k=n-1-j
        if j==k or f[j]+f[k]:break
        f[j]=f[k]=1
        t+=s[j]+s[k]
        if t>m:m=t
print(m)

Submission status: Wrong Answer

Solution code:
n,*s=map(int,open(0).read().split())
*s,=enumerate(s)
m=0
for i in range(1,n+1):
    t=0
    f=[0]*n
    for (i,a),(j,b)in zip(s[:n-1:i],s[:0:-i]):
        if i==j or f[i] or f[j]:break
        f[i]=f[j]=1
        t+=a+b
        if t>m:m=t
print(m)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int, input().split()))
ans = 0
for i in range(1, n):
  l = 0
  r = n-1
  cur = 0
  while True:
    l += i
    r -= i
    if l>=r:
      break
    cur += s[l] + s[r]
    ans = max(ans, cur)
print(ans)

Submission status: Wrong Answer

Solution code:
n,*s=map(int,open(0).read().split())
*s,=enumerate(s)
m=0
for i in range(1,n+1):
    t=0
    f=[0]*n
    for (i,a),(j,b)in zip(s[::i],s[::-i]):
        if i==j or f[i] or f[j]:break
        f[i]=f[j]=1
        t+=a+b
        if t>m:m=t
print(m)

Submission status: Wrong Answer

Solution code:
n,*s=map(int,open(0).read().split())
s=[t for t in enumerate(s)]
m=0
for i in range(1,n):
    t=0
    f=[0]*n
    for (i,a),(j,b)in zip(s[::i],s[::-i]):
        if i==j or f[i] or f[j]:break
        f[i]=f[j]=1
        t+=a+b
        if t>m:m=t
print(m)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int, input().split()))
ans = 0
for i in range(1, (n-1)//2+1):
	if i > 1 and (n-1)%i == 0:
		continue
	res = 0
	l, r = i, n-1-i
	while r > i and l != r:
		res += s[l] + s[r]
		ans = max(ans, res)
		l += i
		r -= i
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int, input().split()))
ans = 0
for i in range(1, (n-1)//2+1):
	if i > 1 and (n-1)%i == 0:
		continue
	res = 0
	l, r = i, n-1-i
	while r > i:
		res += s[l] + s[r]
		ans = max(ans, res)
		l += i
		r -= i
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int, input().split()))
ans = 0
for i in range(1, (n-1)//2+1):
	if i > 1 and (n-1)%i == 0:
		continue
	res = 0
	l, r = i, n-1-i
	while r > 0:
		res += s[l] + s[r]
		ans = max(ans, res)
		l += i
		r -= i
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def single_input(F): return F.readline().strip("\n")
def line_input(F): return F.readline().strip("\n").split()
  
def solve():
    F = sys.stdin
    N = int(single_input(F))
    S = [int(s) for s in line_input(F)]
    
    maxpoint = 0
    for c in range(1, N//2):
        s, l = 0, N-1
        point = 0
        while l > s and l > c:
            point += S[s] + S[l]
            maxpoint = max(point, maxpoint)
            s += c
            l -= c
    print(maxpoint)
    return 0
  
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys
def single_input(F): return F.readline().strip("\n")
def line_input(F): return F.readline().strip("\n").split()
  
def solve():
    F = sys.stdin
    N = int(single_input(F))
    S = [int(s) for s in line_input(F)]
    DP = [[0 for k in range(N-1)] for c in range(N//2 + 1)]
    maxpoint = 0
    for c in range(1, N//2):
        visited = set()
        for k in range(N//c):
            if N - 1 - (k + 1) * c <= c: break
            a = N - 1 - (k * c)
            if a not in visited and k * c not in visited:
                DP[c][k+1] = DP[c][k] + S[a] + S[k*c]
                maxpoint = max(maxpoint, DP[c][k+1])
                visited |= set([a, k*c])
            else: break
    print(maxpoint)

    return 0
  
if __name__ == "__main__":
    solve()