結果

問題 No.702 中央値を求めよ LIMITED
ユーザー maspymaspy
提出日時 2020-03-20 02:32:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 62 ms / 5,000 ms
コード長 917 bytes
コンパイル時間 1,184 ms
コンパイル使用メモリ 146,756 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-14 21:53:53
合計ジャッジ時間 4,000 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

uint32_t nums[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)
{
    int64_t seed;
    cin >> seed;
    x = seed;
    int N = 10000001;
    int lower = 0;
    int upper = 0;
    uint32_t A = 2140000000;
    uint32_t B = 2155000000;
    int n = 0;
    for (int i = 0; i < 10000001; i++)
    {
        uint32_t x = generate();
        if (x < A)
        {
            lower++;
        }
        else
        {
            if (x > B)
            {
                upper++;
            }
            else
            {
                nums[n] = x;
                n++;
            }
        }
    }
    sort(nums, nums + n);
    uint32_t answer = nums[N / 2 - lower];
    cout << answer << endl;
    return 0;
}
0