結果

問題 No.944 煎っぞ!
ユーザー caleicalei
提出日時 2020-01-05 22:53:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 419 ms / 3,000 ms
コード長 867 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 17,316 KB
最終ジャッジ日時 2024-05-02 10:34:12
合計ジャッジ時間 3,390 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
15,504 KB
testcase_01 AC 56 ms
15,508 KB
testcase_02 AC 57 ms
15,508 KB
testcase_03 AC 64 ms
15,504 KB
testcase_04 AC 53 ms
15,388 KB
testcase_05 AC 55 ms
15,512 KB
testcase_06 AC 58 ms
15,520 KB
testcase_07 AC 61 ms
15,648 KB
testcase_08 AC 60 ms
15,384 KB
testcase_09 AC 57 ms
15,384 KB
testcase_10 AC 27 ms
10,880 KB
testcase_11 AC 34 ms
12,032 KB
testcase_12 AC 29 ms
11,520 KB
testcase_13 AC 29 ms
10,752 KB
testcase_14 AC 35 ms
12,032 KB
testcase_15 AC 30 ms
11,392 KB
testcase_16 AC 27 ms
10,752 KB
testcase_17 AC 27 ms
10,880 KB
testcase_18 AC 33 ms
12,032 KB
testcase_19 AC 33 ms
12,160 KB
testcase_20 AC 60 ms
17,024 KB
testcase_21 AC 57 ms
17,012 KB
testcase_22 AC 58 ms
15,452 KB
testcase_23 AC 58 ms
15,324 KB
testcase_24 AC 53 ms
15,452 KB
testcase_25 AC 54 ms
15,332 KB
testcase_26 AC 54 ms
15,456 KB
testcase_27 AC 61 ms
16,464 KB
testcase_28 AC 27 ms
10,880 KB
testcase_29 AC 26 ms
10,752 KB
testcase_30 AC 58 ms
17,316 KB
testcase_31 AC 419 ms
15,584 KB
testcase_32 AC 236 ms
15,456 KB
testcase_33 AC 128 ms
15,420 KB
testcase_34 AC 132 ms
15,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 2020/01/05
# 累積和

from itertools import accumulate

n=int(input())
a=list(map(int,input().split()))
A=list(accumulate(a))
sum_a=A[-1]
max_a=max(a)

def divisors(n):
    div=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            div.append(i)
            if i!=n//i:
                div.append(n//i)
    div.sort()
    return div


def search(arr,key,low,high):
    
    while True:
        mid=(high+low)//2
        if mid>=len(arr) or high<0 or low>high:
            return -1

        if arr[mid]==key:
            return mid

        elif arr[mid]>key:
            high=mid-1
        else:
            low=mid+1
        

div=divisors(sum_a)
res=[i for i in div if i>=max_a]


for r in res:
    div=sum_a//r
    for d in range(r,sum_a+1,r):
        ret=search(A,d,0,len(A))
        if ret<0:break
    else:
        print(div)
        exit()
0