結果

問題 No.2486 Don't come next to me
ユーザー takumaiq
提出日時 2023-09-27 23:03:35
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 286 ms / 2,000 ms
コード長 324 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 32,568 KB
最終ジャッジ日時 2024-07-20 17:30:37
合計ジャッジ時間 4,472 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())
A=list(map(int,input().split()))

B=[]
if A[0]!=1:
  B.append(A[0]-1)
for i in range(M-1):
  B.append(A[i+1]-A[i]-1)
if A[-1]!=N:
  B.append(N-A[-1])

def calc(n):
  if n==1:
    return 0
  elif n%2==1:
    return 2*calc((n-1)//2)+1
  else:
    return 0

ans=sum(b-calc(b) for b in B)
print(ans)
0