結果

問題 No.2300 Substring OR Sum
ユーザー hitonanode
提出日時 2023-05-12 22:29:04
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 412 bytes
コンパイル時間 994 ms
コンパイル使用メモリ 86,616 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-28 19:00:36
合計ジャッジ時間 2,574 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (auto &x : A) cin >> x;

    unsigned long long ret = 0;

    for (int d = 27; d >= 0; --d, ret *= 2) {
        int last = 0;
        for (int i = 0; i < N; ++i) {
            if ((A[i] >> d) & 1) last = i + 1;
            ret += last;
        }
    }

    cout << ret / 2 << endl;
}
0