結果

問題 No.2486 Don't come next to me
ユーザー 259-Momone
提出日時 2023-09-29 22:17:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 4,505 ms
コンパイル使用メモリ 224,488 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-22 16:20:17
合計ジャッジ時間 6,379 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/extc++.h>

int main() {
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    vector<unsigned long> A(M);
    adjacent_difference(istream_iterator<unsigned long>{cin}, istream_iterator<unsigned long>{}, begin(A));
    A.erase(begin(A));
    
    unsigned long ans{};
    for(auto a : A){
        --a;
        unsigned long x{};
        while(a > 1 && a & 1){
            a /= 2;
            ++x;
        }
        ans += a << x;
    }
    cout << ans << endl;
    return 0;
}
0