結果

問題 No.2221 Set X
ユーザー titiatitia
提出日時 2023-02-19 00:55:33
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 807 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 86,792 KB
実行使用メモリ 81,048 KB
最終ジャッジ日時 2023-09-27 12:39:13
合計ジャッジ時間 7,726 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
75,956 KB
testcase_01 AC 74 ms
71,612 KB
testcase_02 AC 74 ms
71,300 KB
testcase_03 AC 75 ms
71,532 KB
testcase_04 AC 74 ms
71,228 KB
testcase_05 AC 74 ms
71,576 KB
testcase_06 AC 75 ms
71,500 KB
testcase_07 AC 73 ms
71,356 KB
testcase_08 AC 83 ms
75,888 KB
testcase_09 AC 77 ms
75,548 KB
testcase_10 AC 87 ms
75,908 KB
testcase_11 AC 82 ms
75,916 KB
testcase_12 AC 84 ms
75,720 KB
testcase_13 AC 85 ms
75,680 KB
testcase_14 AC 90 ms
75,868 KB
testcase_15 AC 86 ms
75,920 KB
testcase_16 AC 350 ms
80,552 KB
testcase_17 AC 178 ms
77,320 KB
testcase_18 AC 402 ms
81,048 KB
testcase_19 AC 168 ms
77,192 KB
testcase_20 AC 279 ms
78,628 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

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

    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