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:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    s = LI()
    ans = 0
    for c in range(1,n+1):
        K = (n-1)//c
        dp = [0]*(K+1)
        dp[0] = 0
        S = set([0,n-1])
        for k in range(1,K+1):
            i = n-1-k*c
            if i in S:
                break
            S.add(i)
            j = k*c
            if j in S:
                break
            S.add(j)
            cost = s[i]+s[j]
            dp[k] = dp[k-1]+cost
        m = max(dp)
        if ans < m:
            ans = m
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()-1
    s = LI()
    ans = 0
    for c in range(1,n+1):
        K = n//c
        dp = [0]*(K+1)
        dp[0] = 0
        S = set()
        for k in range(1,K+1):
            i = n-k*c
            if i in S or i < 0:
                break
            S.add(i)
            j = k*c
            if j in S or j > n:
                break
            S.add(j)
            cost = s[i]+s[j]
            dp[k] = dp[k-1]+cost
        m = max(dp)
        if ans < m:
            ans = m
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()-1
    s = LI()
    ans = 0
    for c in range(1,n+1):
        K = n//c
        dp = [0]*(K+1)
        dp[0] = s[n]
        S = set([0,n])
        for k in range(1,K+1):
            i = n-k*c
            if i in S or i < 0:
                break
            S.add(i)
            j = k*c
            if j in S or j > n:
                break
            S.add(j)
            cost = s[i]+s[j]
            dp[k] = dp[k-1]+cost
        m = max(dp)
        if ans < m:
            ans = m
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()-1
    s = LI()
    ans = 0
    for c in range(1,n):
        K = n//c+1
        dp = [0]*(K+1)
        dp[0] = s[n]
        S = set([0,n])
        for k in range(1,K+1):
            i = n-k*c
            if i in S or i < 0:
                cost = -float("inf")
            else:
                cost = s[i]
                S.add(i)
            j = k*c
            if j in S or j > n:
                cost -= float("inf")
            else:
                cost += s[j]
                S.add(j)
            dp[k] = dp[k-1]+cost
        m = max(dp)
        if ans < m:
            ans = m
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()-1
    s = LI()
    ans = 0
    for c in range(1,n+1):
        K = n//c
        dp = [0]*(K+1)
        dp[0] = s[n]
        S = set([0,n])
        for k in range(1,K+1):
            i = n-k*c
            cost = s[i]
            if i in S:
                cost -= float("inf")
            else:
                S.add(i)
            j = k*c
            cost += s[j]
            if j in S:
                cost -= float("inf")
            else:
                S.add(j)
            dp[k] = dp[k-1]+cost
        m = max(dp)
        if ans < m:
            ans = m
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
N, *S = map(int, open(0).read().split())

ans = 0
for dx in range(1, N):

    k, r = divmod(N - 1, dx)
    if r == 0:
        k = (k + 1) // 2

    if k <= 1:
        continue

    ans = max(ans, sum(S[dx:dx * k:dx]) + sum(S[(N - 1) - dx:(N - 1) - dx * k:-dx]))

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = list(map(int, input().split()))
answer = 0
for i in range(1, int(N/2)):
    left = i
    right = N-1-i
    sum = 0
    while N/2<right:
        sum += s[left] + s[right]
        answer = max([answer,sum])
        right -= i
        left += i

print(answer)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(map(int,input().split()))
t=[0]*n
for i in range(n):
    if i==n-1-i:
        continue
    t[i]+=s[i]+s[n-1-i]
ans=0
for c in range(1,n//2):
    num=0
    s_max=0
    if (n-1)%c!=0:
        for k in range((n-1)//c+1):
            num+=t[c*k]
            s_max=max(s_max,num)
    ans=max(ans,s_max)

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(map(int,input().split()))
t=[0]*n
for i in range(n):
    if i==n-1-i:
        continue
    t[i]+=s[i]+s[n-1-i]
ans=0
for c in range(1,n//2):
    num=0
    s_max=0
    if (n-1)%c==0:
        for k in range((n//2)//c+1):
            if n//2<=c*k:
                break
            num+=t[c*k]
            s_max=max(s_max,num)
    else:
        for k in range((n-1)//c+1):
            num+=t[c*k]
            s_max=max(s_max,num)
    ans=max(ans,s_max)

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(map(int,input().split()))
t=[0]*n
for i in range(n):
    if i==n-1-i:
        continue
    t[i]+=s[i]+s[n-1-i]
ans=0
for c in range(1,n//2):
    num=0
    s_max=0
    if (n-1)%c==0:
        for k in range(((n-1)//2)//c+1):
            if n%2==1 and n//2==c*k:
                continue
            num+=t[c*k]
            s_max=max(s_max,num)
    else:
        for k in range((n-1)//c+1):
            num+=t[c*k]
            s_max=max(s_max,num)
    ans=max(ans,s_max)

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(map(int,input().split()))
t=[0]*n
for i in range(n):
    if i==n-1-i:
        continue
    t[i]+=s[i]+s[n-1-i]
ans=0
for c in range(1,n):
    num=0
    s_max=0
    if (n-1)%c==0:
        for k in range(((n-1)//2)//c+1):
            if n%2==1 and n//2==c*k:
                continue
            num+=t[c*k]
            s_max=max(s_max,num)
    else:
        for k in range((n-1)//c+1):
            num+=t[c*k]
            s_max=max(s_max,num)
    ans=max(ans,s_max)

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(map(int,input().split()))
t=[0]*n
for i in range(n):
    if i==n-1-i:
        continue
    t[i]+=s[i]+s[n-1-i]
ans=0
for c in range(1,n):
    num=0
    s_max=0
    if (n-1)%c==0:
        for k in range(((n+1)//2-1)//c+1):
            num+=t[c*k]
            s_max=max(s_max,num)
    else:
        for k in range((n-1)//c+1):
            num+=t[c*k]
            s_max=max(s_max,num)
    ans=max(ans,s_max)

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(map(int,input().split()))
t=[0]*n
for i in range(n):
    t[i]+=s[i]+s[n-1-i]

ans=0
for c in range(2,n):
    if (n-1)%c==0:
        continue
    num=0
    for k in range((n-1)//c+1):
        num+=t[c*k]
    ans=max(ans,num)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(raw_input())
s = np.array(map(int, raw_input().split()), dtype=int)

# A = N-1
ans = 0

# C = A - B
# n * C + B = N-1
# C max N-1/C
for C in xrange(1, N-1):
    n = (N-1)/C
    B = N - 1 - n * C
    if B>0:
        res = np.sum(s[N-1:0:-C]) + np.sum(s[C:N:C])
        if res > ans:
            ans = res
            
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):
    res = 0
    for k in range((N-1)//c+1):
        a = N-1-c*k
        b = a-c
        res+=s[c*k]+s[-c*k-1]
        if a<=b or a%c == 0:
            continue
        ans = max(ans, res)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 18
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.add(i)
            divisors.add(n // i)
    return divisors


n = I()
s = LI()
divisors = make_divisors(n - 1)
ans = -INF
for c in range(2, n):
    if c in divisors:
        continue
    ret = 0
    for j in range(c, n - 1, c):
        ret += s[j]
    for k in range(n - 1, 0, -c):
        ret += s[k]
    ans = max(ans, ret)


print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
N = int(input())
S = [int(_) for _ in input().split()]

ans = 0
for i in range(1, N - 1):
    if (N - 1) % i:
        maxj = (N - 1) // i + 1
    else:
        maxj = ((N - 1) // i - 1) // 2 + 1
    dp = itertools.accumulate(
        x + y for x, y in zip(S[:i * maxj:i], S[-1:-1 - i * maxj:-i]))
    ans = max(ans, max(dp))
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
N = int(input())
S = [int(_) for _ in input().split()]

ans = 0
for i in range(1, N):
    if (N - 1) % i:
        maxj = (N - 1) // i
    else:
        maxj = (N - 1) // i // 2
    if maxj < 1:
        continue
    ans = max(
        ans,
        max(
            itertools.accumulate([
                x + y for x, y in zip(S[-1:-1 - i * maxj:-i], S[:i * maxj:i])
            ])))
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
N = int(input())
S = [int(_) for _ in input().split()]

ans = 0
for i in range(1, N):
    if (N - 1) % i:
        maxj = N // i + 1
    else:
        maxj = N // i // 2 + 1
    if maxj < 1:
        continue
    ans = max(
        ans,
        max(
            itertools.accumulate([
                x + y for x, y in zip(S[-1:-1 - i * maxj:-i], S[:i * maxj:i])
            ])))
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [int(_) for _ in input().split()]

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

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

N = int(readline())
S = list(map(int,read().split()))

answer = 0
for d in range(1,N):
    n = (N-1-d)//d
    if (N-1)%d == 0:
        n = ((N-1)//d+1)//2
    if n <= 1:
        continue
    x = max(itertools.accumulate(x+y for x,y in zip(S[d:d*n:d],S[N-1-d:N-1-d*n:-d])))
    if answer < x:
        answer = x

print(answer)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
S = np.array(read().split(),np.int64)

def F(d):
    # 公差を固定
    L = S[::d].cumsum()
    R = S[::-d].cumsum()
    if (N-1)%d == 0:
        n = (N-1)//d
        x = np.arange(1,n+2)
        bl = (x+x <= n+1)
        L = L[bl]; R = R[bl]
    return (L+R).max()

def G(n):
    # 項数n+1を固定
    D = (N-1)//n
    L = np.zeros(D+1,np.int64)
    R = np.zeros(D+1,np.int64)
    for i in range(1,n+1):
        L += S[:i*(D+1):i]
        R += S[::-1][:i*(D+1):i]
    ok = np.ones(D+1,np.bool)
    overlap = (np.arange(D+1) * (n+n) >= N-1)
    overlap[1:] &= ((N-1)%np.arange(1,D+1) == 0)
    x = L+R
    x[overlap] = 0
    return x.max()

L = int((N-1)**.5 + 10)
L = min(N-1,L)

x = max(F(n) for n in range(1,L+1))
y = max(F(n) for n in range(1,L+1))
answer = max(x,y)
print(answer)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
S = np.array(read().split(),np.int64)

def F(d):
    # 公差を固定
    L = S[::d].cumsum()
    R = S[::-d].cumsum()
    if (N-1)%d == 0:
        n = (N-1)//d
        x = np.arange(1,n+2)
        bl = (x+x <= n+1)
        L = L[bl]; R = R[bl]
    return (L+R).max()

def G(n):
    # 項数n+1を固定
    D = (N-1)//n
    L = np.zeros(D+1,np.int64)
    R = np.zeros(D+1,np.int64)
    for i in range(1,n+1):
        L += S[:i*(D+1):i]
        R += S[::-1][:i*(D+1):i]
    ok = np.ones(D+1,np.bool)
    overlap = (np.arange(D+1) * (n+n) >= N-1)
    overlap[1:] &= ((N-1)%np.arange(1,D+1) == 0)
    x = L+R
    x[overlap] = 0
    return x.max()

L = int((N-1)**.5)

x = max(F(n) for n in range(1,L+1))
y = max(F(n) for n in range(1,L+1))
answer = max(x,y)
print(answer)

Submission status: Wrong Answer

Solution code:

N = int(input())

s = list(map(int,input().split()))

ans = 0

for c in range(N-1):

    if c == 0 or (N-1) % c == 0:
        continue

    for j in range((N-1) // c):
        
        a = (N-1) % c + c * j
        b = a - c

        now = a
        ssum = s[a]

        while now != N-1:

            now -= b
            ssum += s[now]

            now += a
            ssum += s[now]

        ans = max(ssum,ans)

print (ans)

Submission status: Wrong Answer

Solution code:

N = int(input())

s = list(map(int,input().split()))

ans = 0

for c in range(N-1):

    if c == 0 or (N-1) % c == 0:
        continue

    a = (N-1) % c
    b = a - c

    now = a
    ssum = s[a]

    while now != N-1:

        now -= b
        ssum += s[now]

        now += a
        ssum += s[now]

    ans = max(ssum,ans)

print (ans)

Submission status: Wrong Answer

Solution code:
def getlist():
	return list(map(int, input().split()))

#初期化
N = int(input())
s = getlist()

#計算
ans = 0
for i in range(1, N):
	if (N - 1) % i == 0:
		val = 0
		for j in range(N):
			if i * j < (N - 1) // 2:
				val += s[i * j] + s[-1 - (i * j)]
				ans = max(ans, val)
			else:
				break

	else:
		val = 0
		for j in range(N):
			if i * j < N - 1:
				val += s[i * j] + s[-1 - (i * j)]
				ans = max(ans, val)
			else:
				break

print(ans)

Submission status: Wrong Answer

Solution code:
def getlist():
	return list(map(int, input().split()))

#初期化
N = int(input())
s = getlist()

#計算
ans = 0
for i in range(1, N):
	if (N - 1) % i == 0:
		val = 0
		for j in range(N):
			if i * j < (N - 1) // 2:
				val += s[i * j] + s[-1 - (i * j)]
				ans = max(ans, val)
			else:
				break

	else:
		val = 0
		for j in range(N):
			if i * j < N - 1 - i:
				val += s[i * j] + s[-1 - (i * j)]
				ans = max(ans, val)
			else:
				break

print(ans)

Submission status: Wrong Answer

Solution code:
def getlist():
	return list(map(int, input().split()))

#初期化
N = int(input())
s = getlist()

#計算
ans = 0
for i in range(1, N):
	if (N - 1) % i == 0:
		val = 0
		for j in range(N):
			if i * j < (N - 1) // 2:
				val += s[i * j] + s[-1 - (i * j)]
				ans = max(ans, val)
			else:
				break

	else:
		val = 0
		for j in range(N):
			if i * j <= N - 1 - i:
				val += s[i * j] + s[-1 - (i * j)]
				ans = max(ans, val)
			else:
				break

print(ans)

Submission status: Wrong Answer

Solution code:
def getlist():
	return list(map(int, input().split()))

N = int(input())
s = getlist()

ans = 0
for i in range(1, N):
	if (N - 1) % i != 0:
		left = 0
		right = 0
		for j in range(N):
			if (i + 1) * j <= N - 1:
				left += s[i * j]
			else:
				break

		for j in range(N):
			if (i + 1) * j <= N - 1:
				right += s[-1 - (i * j)]
			else:
				break
		ans = max(ans, left + right)
print(ans)

Submission status: Wrong Answer

Solution code:
def getlist():
	return list(map(int, input().split()))

N = int(input())
s = getlist()

ans = 0
for i in range(1, N):
	if (N - 1) % i != 0:
		left = 0
		right = 0
		for j in range(N):
			if i * j <= N - 1:
				left += s[i * j]
			else:
				break

		for j in range(N):
			if i * j <= N - 1:
				right += s[-1 - (i * j)]
			else:
				break
		ans = max(ans, left + right)
print(ans)

Submission status: Wrong Answer

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

ans = 0
for q in range(1, N - 1):
    k = 0
    a1 = 0
    seen = set()

    p = N - 1 - k * q
    while p > 1:
        if k * q in seen:
            break
        seen.add(k * q)
        if p in seen:
            break
        seen.add(p)

        a1 = a1 + s[p] + s[k * q]
        ans = max(ans, a1)

        k += 1
        p = N - 1 - k * q

print(ans)

Submission status: Wrong Answer

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

ans = 0
for q in range(1, N - 1):
    k = 0
    a1 = 0
    seen = set()

    p = N - 1 - k * q
    while p > 1:
        if p in seen:
            break
        seen.add(p)
        if k * q in seen:
            break
        seen.add(k * q)

        a1 = a1 + s[p] + s[k * q]
        ans = max(ans, a1)

        k += 1
        p = N - 1 - k * q

print(ans)

Submission status: Wrong Answer

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

ans = 0
for q in range(1, N):
    k = 0
    a1 = 0
    seen = set()

    p = N - 1 - k * q
    while p > 1:
        if p in seen:
            break
        seen.add(p)
        if k * q in seen:
            break
        seen.add(k * q)

        a1 = a1 + s[p] + (s[k * q] if p < N - 1 else 0)
        ans = max(ans, a1)

        k += 1
        p = N - 1 - k * q

print(ans)

Submission status: Wrong Answer

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

ans = 0
for q in range(2, N):
    k = 0
    a1 = 0
    seen = set()

    p = N - 1 - k * q
    while p > 1:
        if p in seen:
            break
        seen.add(p)
        if k * q in seen:
            break
        seen.add(k * q)

        a1 = a1 + s[p] + s[k * q]
        ans = max(ans, a1)

        k += 1
        p = N - 1 - k * q

print(ans)

Submission status: Wrong Answer

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

ans = 0
for q in range(2, N):
    k = 0
    a1 = 0
    seen = set()

    p = N - 1 - k * q
    while p > 0:
        if p in seen:
            break
        seen.add(p)
        if k * q in seen:
            break
        seen.add(k * q)

        a1 = a1 + s[p] + s[k * q]
        ans = max(ans, a1)

        k += 1
        p = N - 1 - k * q

print(ans)

Submission status: Wrong Answer

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

ans = 0
for q in range(1, N):
    k = 0
    a1 = 0
    seen = set()

    p = N - 1 - k * q
    while p > 0:
        if p in seen:
            break
        seen.add(p)
        if k * q in seen:
            break
        seen.add(k * q)

        a1 = a1 + s[p] + s[k * q]
        ans = max(ans, a1)

        k += 1
        p = N - 1 - k * q

print(ans)

Submission status: Wrong Answer

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

ans = 0
for q in range(1, N):
    # p = N - 1 - q
    k = 0
    a2 = 0
    p = N - 1 - k * q
    seen = set()

    while N - 1 - k * q > 1:
        # print("Add", N - 1 - k * q, k * q)
        if N - 1 - k * q in seen:
            break
        seen.add(N - 1 - k * q)
        if k * q in seen:
            break
        seen.add(k * q)

        a1 = a2 + s[N - 1 - k * q] + s[k * q]
        ans = max(ans, a1)
        a2 = a1
        k += 1

print(ans)

Submission status: Wrong Answer

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

def calc(p, q):
    ans = s[p]
    if p == N - 1:
        return ans

    pos1 = 0
    pos2 = p
    pos3 = q
    # print("Add", s[p])
    seen = set()
    seen.add(p)
    while pos3 < N - 1:
        if pos3 in seen:
            return -10000000000000000000000
        seen.add(pos3)
        # print("Add", s[pos3])
        ans += s[pos3]
        t = pos3
        pos3 = pos3 + pos2 - pos1
        pos1 = pos2
        pos2 = t
    if pos3 == N - 1:
        ans += s[pos3]

    return ans

ans = 0
for q in range(1, N):
    p = N - 1 - q
    while p > 1:
        a1 = calc(p, q)
        # print("Try", p, q, a1)
        ans = max(ans, a1)
        p -= q

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    S = list(map(int, input().split()))
    ans = 0
    for C in range(1, N):
        cs = 0
        for k in range(1, (N-1)//C+1):
            a = C*k
            b = N - a - 1
            if a >= b and (N-1) % C == 0:
                break
            cs += S[a] + S[b]
            ans = max(cs, ans)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    S = list(map(int, input().split()))
    ans = 0
    for C in range(1, N):
        cs = 0
        for a in range(0, N, C):
            b = N - a - 1
            if a >= b and (N-1) % C == 0:
                break
            cs += S[a] + S[b]
            ans = max(cs, ans)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    S = list(map(int, input().split()))
    ans = 0
    for C in range(1, N//2+2):
        cs = 0
        for a in range(0, N, C):
            b = N - a - 1
            if a >= b and (N-1) % C == 0:
                break
            cs += S[a] + S[b]
            ans = max(cs, ans)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    S = list(map(int, input().split()))
    ans = 0
    for C in range(1, N//2+2):
        cs = 0
        seen = set()
        for a in range(0, N, C):
            b = N - a - 1
            if a == b or a in seen or b in seen:
                break
            seen.add(a)
            seen.add(b)
            cs = cs + S[a] + S[b]
            ans = max(cs, ans)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    S = list(map(int, input().split()))
    ans = 0
    for C in range(1, N//2+1):
        cs = 0
        seen = set()
        for a in range(0, N, C):
            b = N - a - 1
            if a == b or a in seen or b in seen:
                break
            seen.add(a)
            seen.add(b)
            cs = cs + S[a] + S[b]
            ans = max(cs, ans)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    S = list(map(int, input().split()))
    ans = 0
    for i in range(N//2):
        cs = 0
        added = set()
        for j in range(-(-N//(i+1))):
            a = (i+1)*j
            b = N-(i+1)*j-1
            if a == b or a in added or b in added:
                break
            added.add(a)
            added.add(b)
            cs = cs + S[a] + S[b]
            ans = max(cs, ans)
    print(ans)


if __name__ == "__main__":
    main()

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]
    # dp[C][k+1] = dp[C][k] + S[]
    # print(R)
    dp = [[0] * (-(-M//(i+1))+1) for i in range(M)]
    ans = 0
    for i in range(M):
        for j in range(-(-M//(i+1))):
            dp[i][j+1] = dp[i][j] + R[(i+1)*j]
            ans = max(dp[i][j+1], ans)
        # print(dp[i])
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(item) for item in input().split()]

ans = 0
for c in range(1, n):
    visited = set([0, n-1])
    total = 0
    for k in range(1, n):
        odd = n - 1 - k*c
        even = k * c
        if even >= n - 1:
            break
        if even in visited:
            break
        visited.add(even)
        if odd in visited:
            break
        visited.add(odd)
        total += a[odd] + a[even]
        ans = max(ans, total)
        # print(c, k, total)
        # print(visited)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(item) for item in input().split()]

ans = 0
for c in range(1, n):
    visited = set()
    val = 0
    total = 0
    for k in range(1, n):
        if k * c >= n - 1:
            break
        odd = n - 1 - k*c
        even = k * c
        if even in visited or odd in visited or odd == even:
            break
        visited.add(odd)
        visited.add(even)
        total += a[odd] + a[even]
        val = max(val, total)
        # print(c, k, total)
        # print(visited)
    ans = max(ans, val)
print(ans)

Submission status: Wrong Answer

Solution code:
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
S = list(map(int, sys.stdin.readline().split()))


def count_max(diff):
    # 左右対称に diff 間隔でとるときの最大
    L = 0
    r = N - 1
    ret = 0
    cumsum = 0
    while 0 <= r and L <= N - 1 and r != L and L - r != diff:
        cumsum += S[L] + S[r]
        ret = max(ret, cumsum)
        L += diff
        r -= diff
    return ret


ans = 0
for diff in range(1, N // 2 + 1):
    ans = max(ans, count_max(diff))
print(ans)

Submission status: Wrong Answer

Solution code:
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
S = list(map(int, sys.stdin.readline().split()))


def count_max(diff):
    # 左右対称に diff 間隔でとるときの最大
    L = 0
    r = N - 1
    ret = 0
    cumsum = 0
    while 0 <= r and L <= N - 1 and r != L and L - r != diff:
        cumsum += S[L] + S[r]
        ret = max(ret, cumsum)
        L += diff
        r -= diff
    return ret


ans = 0
for diff in range(1, N // 2):
    ans = max(ans, count_max(diff))
print(ans)