結果

問題 No.702 中央値を求めよ LIMITED
ユーザー sekiya9311sekiya9311
提出日時 2018-06-15 23:04:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 463 ms / 5,000 ms
コード長 811 bytes
コンパイル時間 1,354 ms
コンパイル使用メモリ 166,312 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-02 09:18:21
合計ジャッジ時間 14,740 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 447 ms
5,248 KB
testcase_01 AC 443 ms
5,376 KB
testcase_02 AC 446 ms
5,376 KB
testcase_03 AC 443 ms
5,376 KB
testcase_04 AC 447 ms
5,376 KB
testcase_05 AC 448 ms
5,376 KB
testcase_06 AC 448 ms
5,376 KB
testcase_07 AC 451 ms
5,376 KB
testcase_08 AC 452 ms
5,376 KB
testcase_09 AC 446 ms
5,376 KB
testcase_10 AC 441 ms
5,376 KB
testcase_11 AC 444 ms
5,376 KB
testcase_12 AC 443 ms
5,376 KB
testcase_13 AC 463 ms
5,376 KB
testcase_14 AC 457 ms
5,376 KB
testcase_15 AC 447 ms
5,376 KB
testcase_16 AC 446 ms
5,376 KB
testcase_17 AC 452 ms
5,376 KB
testcase_18 AC 442 ms
5,376 KB
testcase_19 AC 458 ms
5,376 KB
testcase_20 AC 447 ms
5,376 KB
testcase_21 AC 441 ms
5,376 KB
testcase_22 AC 442 ms
5,376 KB
testcase_23 AC 446 ms
5,376 KB
testcase_24 AC 451 ms
5,376 KB
testcase_25 AC 451 ms
5,376 KB
testcase_26 AC 446 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

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

const int a = 10000001;

void init() {
    x = seed;
    y = 1;
    z = 2;
    w = 3;
}

int main() {
    cin >> seed;
    uint32_t high = UINT32_MAX, low = 0;
    while (high - low > 1) {
        const uint32_t mid = low + (high - low) / 2;
        init();
        int cnt = 0;
        bool isExist = false;
        for (int i = 0; i < a; i++) {
            if (generate() <= mid) {
                cnt++;
            }
        }
        if (cnt <= a / 2) {
            low = mid;
        } else {
            high = mid;
        }
    }
    cout << high << endl;
}
0