結果

問題 No.702 中央値を求めよ LIMITED
コンテスト
ユーザー rpy3cpp
提出日時 2018-08-12 13:51:07
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 77 ms / 5,000 ms
コード長 862 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 734 ms
コンパイル使用メモリ 82,924 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-08 19:06:01
合計ジャッジ時間 3,533 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

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;
}

uint32_t median = 2'147'483'648;
uint32_t width =      5'000'000;
uint32_t lower_limit = median - width;
uint32_t upper_limit = median + width;


int main(void) {
    int64_t seed; cin >> seed;
    x = seed;
    vector<uint32_t> pool;
    int count_small = 0;
    uint32_t a;
    for (int i = 0; i < 10000001; i++) {
        a = generate();
        if (a < lower_limit){
            ++count_small;
        }else if (a <= upper_limit){
            pool.push_back(a);
        }
    }
    sort(pool.begin(), pool.end());
    int n = 5'000'000 - count_small;
    cout << pool[n] << endl;
    return 0;
}
0