結果

問題 No.2221 Set X
ユーザー titiatitia
提出日時 2023-02-19 00:51:31
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 804 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 86,392 KB
最終ジャッジ日時 2023-09-27 12:37:17
合計ジャッジ時間 8,448 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
75,556 KB
testcase_01 AC 70 ms
71,232 KB
testcase_02 AC 71 ms
71,176 KB
testcase_03 AC 70 ms
71,340 KB
testcase_04 AC 72 ms
71,340 KB
testcase_05 AC 72 ms
70,976 KB
testcase_06 AC 72 ms
71,232 KB
testcase_07 AC 74 ms
71,164 KB
testcase_08 WA -
testcase_09 AC 76 ms
75,488 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 OLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
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:
        print(OK)
        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 j in range(100,ANS+1):
    k=calc2(i)

    if k<ANS:
        ANS=k
        IND=i

    

print(IND)
print(ANS)
0