結果

問題 No.2486 Don't come next to me
ユーザー prin_kemkemprin_kemkem
提出日時 2023-09-29 21:39:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 267 ms / 2,000 ms
コード長 795 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 86,880 KB
実行使用メモリ 117,544 KB
最終ジャッジ日時 2023-09-29 21:39:21
合計ジャッジ時間 7,185 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 264 ms
109,196 KB
testcase_01 AC 259 ms
106,244 KB
testcase_02 AC 217 ms
88,912 KB
testcase_03 AC 245 ms
102,380 KB
testcase_04 AC 247 ms
106,284 KB
testcase_05 AC 242 ms
101,960 KB
testcase_06 AC 244 ms
104,016 KB
testcase_07 AC 210 ms
84,012 KB
testcase_08 AC 210 ms
89,416 KB
testcase_09 AC 258 ms
106,600 KB
testcase_10 AC 251 ms
101,776 KB
testcase_11 AC 217 ms
93,560 KB
testcase_12 AC 201 ms
86,160 KB
testcase_13 AC 267 ms
117,544 KB
testcase_14 AC 220 ms
91,088 KB
testcase_15 AC 249 ms
101,324 KB
testcase_16 AC 207 ms
84,928 KB
testcase_17 AC 216 ms
89,432 KB
testcase_18 AC 215 ms
88,112 KB
testcase_19 AC 215 ms
89,740 KB
testcase_20 AC 185 ms
80,200 KB
testcase_21 AC 174 ms
80,528 KB
testcase_22 AC 170 ms
80,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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