結果

問題 No.2486 Don't come next to me
ユーザー 👑 NachiaNachia
提出日時 2023-09-29 21:03:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 643 bytes
コンパイル時間 905 ms
コンパイル使用メモリ 76,344 KB
実行使用メモリ 4,612 KB
最終ジャッジ日時 2023-09-29 21:03:55
合計ジャッジ時間 2,239 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
4,380 KB
testcase_01 AC 29 ms
4,376 KB
testcase_02 AC 10 ms
4,380 KB
testcase_03 AC 21 ms
4,380 KB
testcase_04 AC 28 ms
4,384 KB
testcase_05 AC 21 ms
4,376 KB
testcase_06 AC 24 ms
4,376 KB
testcase_07 AC 5 ms
4,384 KB
testcase_08 AC 10 ms
4,376 KB
testcase_09 AC 28 ms
4,516 KB
testcase_10 AC 22 ms
4,380 KB
testcase_11 AC 13 ms
4,376 KB
testcase_12 AC 7 ms
4,376 KB
testcase_13 AC 38 ms
4,612 KB
testcase_14 AC 11 ms
4,376 KB
testcase_15 AC 21 ms
4,376 KB
testcase_16 AC 6 ms
4,376 KB
testcase_17 AC 10 ms
4,380 KB
testcase_18 AC 9 ms
4,376 KB
testcase_19 AC 10 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const i64 INF = 1001001001001001001;

void testcase(){
    i64 N, M; cin >> N >> M;
    vector<i64> A(M); rep(i,M) cin >> A[i];
    i64 ans = 0;
    rep(i,M-1){
        i64 a = A[i+1] - A[i] - 1;
        i64 t = 1;
        while(a != 1 && a%2 == 1){
            a /= 2; t *= 2;
        }
        ans += a * t;
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    testcase();
    return 0;
}
0