結果

問題 No.2486 Don't come next to me
ユーザー tassei903tassei903
提出日時 2023-09-29 21:07:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 166 ms / 2,000 ms
コード長 585 bytes
コンパイル時間 676 ms
コンパイル使用メモリ 86,860 KB
実行使用メモリ 115,420 KB
最終ジャッジ日時 2023-09-29 21:07:44
合計ジャッジ時間 4,956 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 157 ms
107,952 KB
testcase_01 AC 147 ms
102,324 KB
testcase_02 AC 111 ms
83,968 KB
testcase_03 AC 135 ms
95,880 KB
testcase_04 AC 138 ms
101,040 KB
testcase_05 AC 127 ms
95,692 KB
testcase_06 AC 139 ms
96,260 KB
testcase_07 AC 109 ms
79,956 KB
testcase_08 AC 108 ms
85,084 KB
testcase_09 AC 149 ms
101,888 KB
testcase_10 AC 136 ms
96,048 KB
testcase_11 AC 115 ms
88,508 KB
testcase_12 AC 99 ms
81,060 KB
testcase_13 AC 166 ms
115,420 KB
testcase_14 AC 118 ms
85,836 KB
testcase_15 AC 133 ms
95,840 KB
testcase_16 AC 106 ms
80,020 KB
testcase_17 AC 112 ms
84,312 KB
testcase_18 AC 112 ms
83,524 KB
testcase_19 AC 116 ms
84,452 KB
testcase_20 AC 67 ms
71,392 KB
testcase_21 AC 68 ms
71,220 KB
testcase_22 AC 70 ms
71,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################

def f(x):
    if x == 0:
        return 0
    if x == 1:
        return 1
    if x % 2 == 0:
        return x
    return f((x-1)//2) * 2

n, m = na()
a = na()
ans = 0
for i in range(m-1):
    ans += f(a[i+1] - a[i] - 1)

print(ans)
0