結果

問題 No.2486 Don't come next to me
ユーザー takumaiqtakumaiq
提出日時 2023-09-27 23:03:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 220 ms / 2,000 ms
コード長 324 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 10,820 KB
実行使用メモリ 33,152 KB
最終ジャッジ日時 2023-09-27 23:07:50
合計ジャッジ時間 3,933 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 199 ms
31,148 KB
testcase_01 AC 169 ms
28,988 KB
testcase_02 AC 58 ms
14,056 KB
testcase_03 AC 136 ms
21,720 KB
testcase_04 AC 162 ms
26,384 KB
testcase_05 AC 121 ms
22,864 KB
testcase_06 AC 132 ms
24,676 KB
testcase_07 AC 36 ms
11,392 KB
testcase_08 AC 62 ms
14,128 KB
testcase_09 AC 172 ms
29,140 KB
testcase_10 AC 130 ms
23,064 KB
testcase_11 AC 82 ms
17,360 KB
testcase_12 AC 45 ms
12,640 KB
testcase_13 AC 220 ms
33,152 KB
testcase_14 AC 66 ms
14,580 KB
testcase_15 AC 128 ms
21,948 KB
testcase_16 AC 38 ms
11,308 KB
testcase_17 AC 61 ms
13,744 KB
testcase_18 AC 61 ms
13,356 KB
testcase_19 AC 62 ms
14,768 KB
testcase_20 AC 14 ms
7,816 KB
testcase_21 AC 14 ms
7,836 KB
testcase_22 AC 14 ms
7,860 KB
権限があれば一括ダウンロードができます

ソースコード

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