結果

問題 No.702 中央値を求めよ LIMITED
ユーザー merom686
提出日時 2025-02-21 14:22:57
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 92 ms / 5,000 ms
コード長 632 bytes
コンパイル時間 3,306 ms
コンパイル使用メモリ 277,032 KB
実行使用メモリ 7,216 KB
最終ジャッジ日時 2025-02-21 14:23:04
合計ジャッジ時間 7,151 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
uint32_t a[1000000];

uint32_t x = 0, y = 1, z = 2, w = 3;
uint32_t generate() {
    uint32_t t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
    return w;
}

int main(void) {
    ll seed; cin >> seed;
    x = seed;

    uint32_t h = 1U << 31, d = 1U << 27;
    int p[2] = {};
    int k = 0;
    for (int i = 0; i < 10000001; i++) {
        auto t = generate();
        if (h - d < t && t < h + d) a[k++] = t;
        else p[t > h]++;
    }
    sort(a, a + k);
    cout << a[5000000 - p[0]] << endl;

    return 0;
}
0