結果

問題 No.2486 Don't come next to me
コンテスト
ユーザー prin_kemkem
提出日時 2023-09-29 21:34:32
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 781 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,108 ms
コンパイル使用メモリ 85,504 KB
実行使用メモリ 124,416 KB
最終ジャッジ日時 2026-04-03 09:48:06
合計ジャッジ時間 6,200 ms
ジャッジサーバーID
(参考情報)
judge4_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other WA * 20
権限があれば一括ダウンロードができます

ソースコード

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)

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

def f(n):
    if n <= 1:
        return n
    if n%2 == 0:
        return n
    if n%4 == 1:
        return n-1
    return ceil_div(n, 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