結果

問題 No.702 中央値を求めよ LIMITED
ユーザー titia
提出日時 2025-07-02 03:59:14
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 91 ms / 5,000 ms
コード長 968 bytes
コンパイル時間 3,157 ms
コンパイル使用メモリ 281,496 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-07-02 03:59:20
合計ジャッジ時間 6,724 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <time.h>
#include <sys/time.h>
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;
}

int main(void) {
    int64_t seed; cin >> seed; 
    x = seed;
    std::vector<uint32_t> data;
    int S=0;
    for (int i = 0; i < 10000001; i++) {
        uint32_t a = generate();
        //cout<< a << endl;
        if (a<2144000000){
        	S-=1;
        }
        else if (a>2151000000){
        	S+=1;
        }
        else{
        	data.push_back(a);
        }
    }
    
    std::sort(data.begin(), data.end());
    //cout << S <<endl;
    
    if (S%2==0){
        cout << data[data.size()/2+S/2] << endl;
    }
    else{
    	if (S>0){
    	cout << data[data.size()/2+S/2] << endl;
    	}
    	else{
    		cout << data[data.size()/2+S/2-1] << endl;
    		
    	}
    }

    return 0;
}
0