結果

問題 No.2486 Don't come next to me
ユーザー hiromi_ayasehiromi_ayase
提出日時 2023-09-29 21:54:25
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 754 bytes
コンパイル時間 5,490 ms
コンパイル使用メモリ 307,008 KB
実行使用メモリ 4,592 KB
最終ジャッジ日時 2023-09-29 21:54:34
合計ジャッジ時間 7,315 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
4,380 KB
testcase_01 AC 32 ms
4,440 KB
testcase_02 AC 10 ms
4,356 KB
testcase_03 AC 22 ms
4,352 KB
testcase_04 AC 30 ms
4,356 KB
testcase_05 AC 23 ms
4,356 KB
testcase_06 AC 25 ms
4,356 KB
testcase_07 AC 6 ms
4,356 KB
testcase_08 AC 11 ms
4,352 KB
testcase_09 AC 31 ms
4,552 KB
testcase_10 AC 24 ms
4,356 KB
testcase_11 AC 15 ms
4,356 KB
testcase_12 AC 7 ms
4,356 KB
testcase_13 AC 40 ms
4,592 KB
testcase_14 AC 12 ms
4,352 KB
testcase_15 AC 24 ms
4,356 KB
testcase_16 AC 6 ms
4,356 KB
testcase_17 AC 10 ms
4,356 KB
testcase_18 AC 9 ms
4,356 KB
testcase_19 AC 11 ms
4,356 KB
testcase_20 AC 2 ms
4,356 KB
testcase_21 AC 2 ms
4,352 KB
testcase_22 AC 1 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/all>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define FAST_IO                \
  ios::sync_with_stdio(false); \
  cin.tie(0);
const i64 INF = 1001001001001001001;
using Modint = atcoder::static_modint<998244353>;

i64 f(i64 x) {
  i64 ret = 0;

  if (x % 2 == 0) {
    return x;
  } else {
    if (x == 1) return 1;
    return f((x - 1) / 2) * 2;
  }
}

int main() {
  FAST_IO

  i64 n;
  int m;
  cin >> n >> m;
  vector a(m, 0LL);
  for (auto i : views::iota(0, m)) {
    cin >> a[i];
  }

  auto ans = 0LL;
  for (auto i : views::iota(0, m - 1)) {
    auto d = a[i + 1] - a[i] - 1;
    ans += f(d);
  }

  cout << ans << endl;
}
0