結果

問題 No.702 中央値を求めよ LIMITED
ユーザー rpy3cpprpy3cpp
提出日時 2018-08-12 13:51:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 862 bytes
コンパイル時間 742 ms
コンパイル使用メモリ 74,432 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-14 21:40:21
合計ジャッジ時間 4,151 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
4,376 KB
testcase_01 AC 83 ms
4,380 KB
testcase_02 AC 83 ms
4,380 KB
testcase_03 AC 83 ms
4,376 KB
testcase_04 AC 83 ms
4,380 KB
testcase_05 AC 83 ms
4,376 KB
testcase_06 AC 83 ms
4,376 KB
testcase_07 AC 83 ms
4,376 KB
testcase_08 AC 83 ms
4,380 KB
testcase_09 AC 83 ms
4,376 KB
testcase_10 AC 83 ms
4,380 KB
testcase_11 AC 83 ms
4,380 KB
testcase_12 AC 83 ms
4,380 KB
testcase_13 AC 83 ms
4,380 KB
testcase_14 AC 83 ms
4,376 KB
testcase_15 AC 83 ms
4,380 KB
testcase_16 AC 83 ms
4,376 KB
testcase_17 AC 83 ms
4,376 KB
testcase_18 AC 83 ms
4,376 KB
testcase_19 AC 83 ms
4,376 KB
testcase_20 AC 83 ms
4,384 KB
testcase_21 AC 83 ms
4,380 KB
testcase_22 AC 83 ms
4,380 KB
testcase_23 AC 83 ms
4,376 KB
testcase_24 AC 83 ms
4,376 KB
testcase_25 AC 83 ms
4,376 KB
testcase_26 AC 82 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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