結果

問題 No.944 煎っぞ!
ユーザー caleicalei
提出日時 2020-01-05 22:31:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 876 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 17,572 KB
最終ジャッジ日時 2024-05-02 10:33:56
合計ジャッジ時間 2,665 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
15,376 KB
testcase_01 AC 56 ms
15,508 KB
testcase_02 AC 54 ms
15,376 KB
testcase_03 AC 52 ms
15,380 KB
testcase_04 AC 57 ms
15,392 KB
testcase_05 AC 53 ms
15,516 KB
testcase_06 AC 54 ms
15,516 KB
testcase_07 AC 53 ms
15,392 KB
testcase_08 AC 52 ms
15,636 KB
testcase_09 AC 53 ms
15,388 KB
testcase_10 AC 27 ms
10,880 KB
testcase_11 AC 31 ms
12,032 KB
testcase_12 AC 29 ms
11,520 KB
testcase_13 AC 25 ms
10,880 KB
testcase_14 AC 32 ms
12,160 KB
testcase_15 AC 28 ms
11,520 KB
testcase_16 WA -
testcase_17 AC 25 ms
10,880 KB
testcase_18 AC 33 ms
12,160 KB
testcase_19 AC 34 ms
12,160 KB
testcase_20 AC 63 ms
17,144 KB
testcase_21 AC 65 ms
16,884 KB
testcase_22 AC 55 ms
15,580 KB
testcase_23 AC 51 ms
15,328 KB
testcase_24 AC 51 ms
15,328 KB
testcase_25 AC 52 ms
15,456 KB
testcase_26 AC 51 ms
15,324 KB
testcase_27 WA -
testcase_28 AC 25 ms
10,752 KB
testcase_29 WA -
testcase_30 AC 59 ms
17,572 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

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(reverse=True)
    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:
    d=sum_a//r

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