結果

問題 No.2486 Don't come next to me
ユーザー miya145592miya145592
提出日時 2023-09-29 22:26:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 386 bytes
コンパイル時間 1,256 ms
コンパイル使用メモリ 86,460 KB
実行使用メモリ 107,296 KB
最終ジャッジ日時 2023-09-29 22:27:02
合計ジャッジ時間 4,943 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
102,936 KB
testcase_01 AC 120 ms
99,352 KB
testcase_02 AC 90 ms
81,916 KB
testcase_03 AC 108 ms
93,856 KB
testcase_04 AC 117 ms
99,268 KB
testcase_05 AC 102 ms
93,596 KB
testcase_06 AC 116 ms
93,724 KB
testcase_07 AC 79 ms
77,760 KB
testcase_08 AC 89 ms
82,996 KB
testcase_09 AC 123 ms
98,560 KB
testcase_10 AC 104 ms
93,768 KB
testcase_11 AC 98 ms
86,700 KB
testcase_12 AC 82 ms
79,460 KB
testcase_13 AC 140 ms
107,296 KB
testcase_14 AC 90 ms
84,072 KB
testcase_15 AC 122 ms
93,700 KB
testcase_16 AC 80 ms
78,484 KB
testcase_17 AC 89 ms
82,588 KB
testcase_18 AC 91 ms
81,840 KB
testcase_19 AC 90 ms
82,760 KB
testcase_20 AC 79 ms
71,168 KB
testcase_21 AC 75 ms
71,088 KB
testcase_22 AC 73 ms
71,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N, M = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(M-1):
    gap = A[i+1]-A[i]
    cnt = 1
    while True:
        if gap==2:
            ans += cnt
            break
        elif gap%2!=0:
            ans += (gap-1)*cnt
            break
        else:
            gap//=2
            cnt*=2
    
print(ans)
0