結果

問題 No.2486 Don't come next to me
コンテスト
ユーザー prin_kemkem
提出日時 2023-09-29 21:39:13
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WJ  
(最新)
AC  
(最初)
実行時間 -
コード長 795 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
最終ジャッジ日時 2026-08-23 09:30:40
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)

ソースコード

diff #
raw source code

from collections import defaultdict, deque, Counter
import copy
from itertools import combinations, permutations, product, accumulate, groupby, chain
from heapq import heapify, heappop, heappush
import math
import bisect
from pprint import pprint
from random import randint
import sys
# sys.setrecursionlimit(700000)
input = lambda: sys.stdin.readline().rstrip('\n')
inf = float('inf')
mod1 = 10**9+7
mod2 = 998244353
def ceil_div(x, y): return -(-x//y)

#################################################

memo = {}
def f(n):
    if n <= 1:
        return n
    if n%2 == 0:
        return n
    if n in memo:
        return memo[n]
    return 2*f((n-1)//2)

N, M = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(M-1):
    ans += f(A[i+1]-A[i]-1)
print(ans)
0