結果

問題 No.2486 Don't come next to me
ユーザー detteiuu
提出日時 2024-12-22 02:18:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 321 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 110,852 KB
最終ジャッジ日時 2024-12-22 02:18:26
合計ジャッジ時間 3,957 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [0]+A+[N+1]
M += 2

ans = 0
for i in range(M-1):
    diff = A[i+1]-A[i]-1
    ans += diff
    if diff%2 == 1:
        cnt = 0
        while diff >= 2 and diff%2 == 1:
            ans -= 2**cnt
            diff //= 2
            cnt += 1

print(ans)
0