結果

問題 No.919 You Are A Project Manager
ユーザー convexineqconvexineq
提出日時 2019-10-25 23:13:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,579 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 87,324 KB
実行使用メモリ 80,564 KB
最終ジャッジ日時 2023-10-11 09:20:13
合計ジャッジ時間 35,847 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 70 ms
71,784 KB
testcase_02 AC 70 ms
71,696 KB
testcase_03 AC 71 ms
71,712 KB
testcase_04 AC 106 ms
78,024 KB
testcase_05 AC 109 ms
77,872 KB
testcase_06 AC 74 ms
71,952 KB
testcase_07 AC 533 ms
78,168 KB
testcase_08 AC 124 ms
77,684 KB
testcase_09 AC 104 ms
76,720 KB
testcase_10 AC 147 ms
77,936 KB
testcase_11 AC 145 ms
77,756 KB
testcase_12 AC 76 ms
71,964 KB
testcase_13 AC 170 ms
77,740 KB
testcase_14 AC 73 ms
71,920 KB
testcase_15 AC 95 ms
76,896 KB
testcase_16 AC 245 ms
77,972 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2,033 ms
79,660 KB
testcase_21 AC 970 ms
79,608 KB
testcase_22 AC 609 ms
78,264 KB
testcase_23 AC 577 ms
78,348 KB
testcase_24 AC 646 ms
78,460 KB
testcase_25 AC 594 ms
78,276 KB
testcase_26 WA -
testcase_27 AC 1,581 ms
79,076 KB
testcase_28 AC 2,307 ms
79,516 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 194 ms
79,280 KB
testcase_33 AC 684 ms
78,356 KB
testcase_34 AC 680 ms
78,176 KB
testcase_35 AC 2,396 ms
79,936 KB
testcase_36 AC 2,389 ms
80,200 KB
testcase_37 AC 2,390 ms
80,564 KB
testcase_38 AC 2,392 ms
80,292 KB
testcase_39 AC 74 ms
71,952 KB
testcase_40 AC 94 ms
76,640 KB
testcase_41 AC 73 ms
72,040 KB
testcase_42 AC 73 ms
71,916 KB
testcase_43 AC 87 ms
77,036 KB
testcase_44 AC 101 ms
76,692 KB
testcase_45 AC 76 ms
72,004 KB
testcase_46 AC 98 ms
77,004 KB
testcase_47 AC 602 ms
78,180 KB
testcase_48 AC 591 ms
78,200 KB
testcase_49 WA -
testcase_50 AC 602 ms
78,348 KB
testcase_51 AC 534 ms
78,632 KB
testcase_52 WA -
testcase_53 AC 536 ms
78,328 KB
testcase_54 AC 98 ms
76,936 KB
testcase_55 AC 71 ms
71,632 KB
testcase_56 AC 70 ms
71,832 KB
testcase_57 AC 69 ms
71,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!
def Eratosthenes(N): #N以下の素数のリストを返す
    #iが素数のときis_prime_list[i]=1,それ以外は0
    N+=1
    is_prime_list = [True]*N
#    is_prime_list[0], is_prime_list[1] = False, False #リストが必要なときはこの2行を有効化
#    for j in range(4,N,2): is_prime_list[j] = False
    m = int(N**0.5)+1
    for i in range(3,m,2):
        if is_prime_list[i]:
            is_prime_list[i*i::2*i]=[False]*((N-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,N,2) if is_prime_list[i]]
#    return is_prime_list

import sys
#sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
ra = list(reversed(a))

p2 = [1,4]
if n >= 4:
    while 2*p2[-1] <= n:
        p2.append(p2[-1]*2)

from itertools import accumulate
primes = Eratosthenes(n)+p2

#print(primes)

def ans(k,a,ra):
    res1 = []
    R1 = [0]
    for i in range(k,n+1,k):
        l = a[i-k:i]
        l.sort()
        res1.append(l[(k+1)//2-1])
    for i in accumulate(res1):
        R1.append(max(R1[-1],i))

#    print(res1,R1)

    res2 = []
    R2 = [0]
    for i in range(k,n+1,k):
        l = ra[i-k:i]
        l.sort()
        res2.append(l[(k+1)//2-1])
    for i in accumulate(res2):
        R2.append(max(R2[-1],i))
#    print(res2,R2)
    
    res1 = R1
    res2 = R2
        
    res = 0    
    for r1,r2 in zip(res1,reversed(res2)):
        res = max(res,r1+r2)
#    print(res*k)
    return(res*k)

c = 0
for p in primes:
    c = max(c,ans(p,a,ra))

print(c)








0