結果

問題 No.2486 Don't come next to me
ユーザー SSRSSSRS
提出日時 2023-09-29 21:23:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 486 bytes
コンパイル時間 1,888 ms
コンパイル使用メモリ 200,036 KB
実行使用メモリ 4,448 KB
最終ジャッジ日時 2023-09-29 21:23:34
合計ジャッジ時間 4,496 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
4,432 KB
testcase_01 AC 98 ms
4,380 KB
testcase_02 AC 29 ms
4,376 KB
testcase_03 AC 70 ms
4,376 KB
testcase_04 AC 95 ms
4,376 KB
testcase_05 AC 71 ms
4,376 KB
testcase_06 AC 78 ms
4,380 KB
testcase_07 AC 16 ms
4,376 KB
testcase_08 AC 31 ms
4,376 KB
testcase_09 AC 94 ms
4,380 KB
testcase_10 AC 71 ms
4,376 KB
testcase_11 AC 42 ms
4,380 KB
testcase_12 AC 21 ms
4,376 KB
testcase_13 AC 126 ms
4,448 KB
testcase_14 AC 35 ms
4,376 KB
testcase_15 AC 71 ms
4,376 KB
testcase_16 AC 16 ms
4,376 KB
testcase_17 AC 29 ms
4,376 KB
testcase_18 AC 31 ms
4,380 KB
testcase_19 AC 32 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  int M;
  cin >> N >> M;
  vector<long long> A(M);
  for (int i = 0; i < M; i++){
    cin >> A[i];
  }
  long long ans = N - M;
  for (int i = 0; i < M - 1; i++){
    if (A[i + 1] - A[i] > 1){
      long long d = A[i + 1] - A[i];
      if (__builtin_popcountll(d) == 1){
        ans -= d / 2 - 1;
      } else {
        ans -= ((long long) 1 << __builtin_ctzll(d)) - 1;
      }
    }
  }
  cout << ans << endl;
}
0