結果

問題 No.2486 Don't come next to me
ユーザー titiatitia
提出日時 2023-09-29 21:35:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 396 ms / 2,000 ms
コード長 401 bytes
コンパイル時間 595 ms
コンパイル使用メモリ 10,808 KB
実行使用メモリ 36,152 KB
最終ジャッジ日時 2023-09-29 21:35:15
合計ジャッジ時間 5,582 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 337 ms
32,248 KB
testcase_01 AC 311 ms
29,860 KB
testcase_02 AC 97 ms
14,276 KB
testcase_03 AC 221 ms
23,332 KB
testcase_04 AC 295 ms
28,876 KB
testcase_05 AC 221 ms
24,456 KB
testcase_06 AC 245 ms
26,708 KB
testcase_07 AC 56 ms
11,436 KB
testcase_08 AC 104 ms
14,680 KB
testcase_09 AC 308 ms
31,640 KB
testcase_10 AC 223 ms
24,992 KB
testcase_11 AC 140 ms
18,200 KB
testcase_12 AC 73 ms
12,632 KB
testcase_13 AC 396 ms
36,152 KB
testcase_14 AC 116 ms
15,416 KB
testcase_15 AC 228 ms
23,632 KB
testcase_16 AC 59 ms
11,432 KB
testcase_17 AC 102 ms
14,620 KB
testcase_18 AC 92 ms
13,900 KB
testcase_19 AC 108 ms
15,624 KB
testcase_20 AC 15 ms
7,812 KB
testcase_21 AC 15 ms
7,864 KB
testcase_22 AC 14 ms
7,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


LIST=[]
for i in range(1,len(A)):
    LIST.append((A[i]-A[i-1]-1,1))

ANS=M

while LIST:
    if LIST[-1][0]<=1:
        LIST.pop()
    elif LIST[-1][0]%2==0:
        LIST.pop()
    else:
        k=LIST[-1][0]
        ko=LIST[-1][1]
        
        ANS+=1*ko
        LIST.pop()

        l=k//2
        LIST.append((l,ko*2))

print(N-ANS)
0