結果

問題 No.2221 Set X
ユーザー titiatitia
提出日時 2023-02-19 01:06:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 689 ms / 2,000 ms
コード長 870 bytes
コンパイル時間 1,217 ms
コンパイル使用メモリ 86,728 KB
実行使用メモリ 91,756 KB
最終ジャッジ日時 2023-09-27 12:45:41
合計ジャッジ時間 16,936 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,204 KB
testcase_01 AC 64 ms
71,100 KB
testcase_02 AC 63 ms
71,312 KB
testcase_03 AC 63 ms
71,388 KB
testcase_04 AC 65 ms
71,240 KB
testcase_05 AC 64 ms
71,320 KB
testcase_06 AC 61 ms
71,124 KB
testcase_07 AC 66 ms
71,124 KB
testcase_08 AC 76 ms
75,564 KB
testcase_09 AC 66 ms
75,688 KB
testcase_10 AC 75 ms
75,668 KB
testcase_11 AC 74 ms
75,752 KB
testcase_12 AC 72 ms
75,676 KB
testcase_13 AC 73 ms
75,640 KB
testcase_14 AC 78 ms
75,720 KB
testcase_15 AC 75 ms
75,700 KB
testcase_16 AC 309 ms
80,284 KB
testcase_17 AC 153 ms
77,080 KB
testcase_18 AC 345 ms
81,112 KB
testcase_19 AC 150 ms
77,456 KB
testcase_20 AC 237 ms
78,452 KB
testcase_21 AC 389 ms
82,688 KB
testcase_22 AC 522 ms
86,080 KB
testcase_23 AC 99 ms
76,428 KB
testcase_24 AC 361 ms
82,332 KB
testcase_25 AC 252 ms
79,924 KB
testcase_26 AC 613 ms
90,092 KB
testcase_27 AC 636 ms
91,300 KB
testcase_28 AC 649 ms
91,456 KB
testcase_29 AC 578 ms
91,296 KB
testcase_30 AC 590 ms
91,212 KB
testcase_31 AC 630 ms
91,320 KB
testcase_32 AC 564 ms
91,556 KB
testcase_33 AC 689 ms
91,484 KB
testcase_34 AC 650 ms
91,548 KB
testcase_35 AC 622 ms
91,492 KB
testcase_36 AC 589 ms
91,292 KB
testcase_37 AC 603 ms
91,436 KB
testcase_38 AC 648 ms
91,756 KB
testcase_39 AC 588 ms
88,452 KB
testcase_40 AC 653 ms
89,448 KB
testcase_41 AC 686 ms
91,468 KB
testcase_42 AC 677 ms
91,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def calc(x):
    score=1
    for i in range(1,N):
        if A[i]//x!=A[i-1]//x:
            score+=1
    return score*(x+1)

def calc2(x):
    score=1
    now=A[0]//x
    OK=0
    
    while True:
        NG=len(A)

        while NG>OK+1:
            mid=(OK+NG)//2

            if A[mid]//x==now:
                OK=mid
            else:
                NG=mid

        if NG==len(A):
            break
        else:
            score+=1
            now=A[NG]//x
            OK=NG

        if score*(x+1)>=ANS:
            return 1<<100

    return score*(x+1)
        
    


N=int(input())
A=list(map(int,input().split()))

ANS=1<<100
IND=-1

for i in range(1,100):
    k=calc(i)

    if k<ANS:
        ANS=k
        IND=i

for i in range(100,ANS+1):
    k=calc2(i)

    if k<ANS:
        ANS=k
        IND=i
    if i>ANS:
        break

    

print(IND)
print(ANS)
0