結果

問題 No.78 クジ付きアイスバー
ユーザー titiatitia
提出日時 2022-01-26 00:41:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 678 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 10,904 KB
実行使用メモリ 7,980 KB
最終ジャッジ日時 2023-08-22 20:33:23
合計ジャッジ時間 2,478 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,856 KB
testcase_01 AC 16 ms
7,812 KB
testcase_02 AC 16 ms
7,852 KB
testcase_03 AC 16 ms
7,924 KB
testcase_04 AC 16 ms
7,900 KB
testcase_05 AC 16 ms
7,856 KB
testcase_06 AC 16 ms
7,812 KB
testcase_07 AC 16 ms
7,828 KB
testcase_08 AC 16 ms
7,860 KB
testcase_09 AC 16 ms
7,808 KB
testcase_10 AC 16 ms
7,864 KB
testcase_11 AC 16 ms
7,784 KB
testcase_12 AC 16 ms
7,812 KB
testcase_13 AC 16 ms
7,792 KB
testcase_14 AC 16 ms
7,780 KB
testcase_15 AC 16 ms
7,792 KB
testcase_16 AC 16 ms
7,916 KB
testcase_17 AC 17 ms
7,912 KB
testcase_18 AC 16 ms
7,784 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 16 ms
7,848 KB
testcase_24 AC 17 ms
7,976 KB
testcase_25 AC 16 ms
7,920 KB
testcase_26 AC 15 ms
7,832 KB
testcase_27 AC 16 ms
7,920 KB
testcase_28 AC 15 ms
7,728 KB
testcase_29 AC 16 ms
7,856 KB
testcase_30 AC 16 ms
7,864 KB
testcase_31 AC 16 ms
7,820 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 16 ms
7,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())
S=list(map(int,list(input().strip())))

SUM=[0]
for s in S:
    SUM.append(SUM[-1]+s)

if N<=SUM[-1]:
    OK=N
else:
    OK=K

def calc(x):
    ANS=(x//N)*SUM[-1]
    if x%N>0:
        ANS+=SUM[(x%N)]
    return ANS

NG=0
while OK>NG+1:
    #print(OK,NG)
    mid=(OK+NG)//2

    NOW=0
    PLUS=mid

    while True:
        #print(NOW,PLUS)
        k=calc(PLUS)-calc(NOW)

        NOW=PLUS
        PLUS=PLUS+k

        if PLUS>=K or PLUS>=mid+2*N:
            break
        if PLUS==NOW:
            break

    #print(mid,NOW,PLUS)

    if PLUS>=K or PLUS>=mid+2*N:
        OK=mid
    else:
        NG=mid

print(OK)
        
        
        

    
0