結果

問題 No.702 中央値を求めよ LIMITED
ユーザー t98slider
提出日時 2022-06-10 06:13:46
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 664 bytes
コンパイル時間 1,506 ms
コンパイル使用メモリ 168,280 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-21 05:42:42
合計ジャッジ時間 20,231 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 9 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;

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(){
    int64_t seed;
    uint32_t ok = -1, ng = 1 << 31 , mid, N = 10000001;
    cin >> seed;
    while(ok + 1 < ng){
        mid = (ok + ng) / 2;
        x = seed, y = 1, z = 2, w = 3;
        uint32_t cnt = 0;
        for(uint32_t i = 0; i < N; i++){
            cnt += (mid >= generate());
        }
        if(cnt < (N + 1) / 2)ok = mid;
        else ng = mid;
    }
    cout << ok + 1 << endl;
}
0