結果

問題 No.2486 Don't come next to me
ユーザー tnakao0123tnakao0123
提出日時 2023-10-03 10:09:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 616 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 41,228 KB
実行使用メモリ 4,524 KB
最終ジャッジ日時 2023-10-03 10:09:33
合計ジャッジ時間 2,685 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
4,380 KB
testcase_01 AC 31 ms
4,384 KB
testcase_02 AC 10 ms
4,380 KB
testcase_03 AC 23 ms
4,384 KB
testcase_04 AC 30 ms
4,380 KB
testcase_05 AC 23 ms
4,380 KB
testcase_06 AC 26 ms
4,384 KB
testcase_07 AC 6 ms
4,384 KB
testcase_08 AC 11 ms
4,380 KB
testcase_09 AC 31 ms
4,384 KB
testcase_10 AC 24 ms
4,380 KB
testcase_11 AC 14 ms
4,380 KB
testcase_12 AC 8 ms
4,380 KB
testcase_13 AC 41 ms
4,524 KB
testcase_14 AC 13 ms
4,380 KB
testcase_15 AC 23 ms
4,380 KB
testcase_16 AC 6 ms
4,384 KB
testcase_17 AC 10 ms
4,384 KB
testcase_18 AC 10 ms
4,380 KB
testcase_19 AC 12 ms
4,384 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2486.cc:  No.2486 Don't come next to me - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_M = 200000;

/* typedef */

typedef long long ll;

/* global variables */

ll as[MAX_M];

/* subroutines */

/* main */

int main() {
  ll n;
  int m;
  scanf("%lld%d", &n, &m);
  for (int i = 0; i < m; i++) scanf("%lld", as + i);

  ll sum = 0;
  for (int i = 0; i + 1 < m; i++) {
    ll d = as[i + 1] - as[i] - 1, c = 1;
    while (d > 1 && (d & 1)) d >>= 1, c <<= 1;
    sum += d * c;
  }

  printf("%lld\n", sum);

  return 0;
}
0