結果

問題 No.702 中央値を求めよ LIMITED
ユーザー ikdikd
提出日時 2018-06-15 23:39:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 812 ms / 5,000 ms
コード長 681 bytes
コンパイル時間 1,044 ms
コンパイル使用メモリ 62,932 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-14 21:15:05
合計ジャッジ時間 24,227 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

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) {
    uint32_t seed; cin >> seed; 
    x = seed;
    int n=10000001;

    long long yes=0, no=4294967296;
    while(no-yes>1){
      auto m=(yes+no)/2;
      x=seed; y=1; z=2; w=3;
      int cnt=0;
      rep(_, n){
        auto a=generate();
        if(a<m) cnt++;
      }
      (cnt<=n/2 ? yes : no) = m;
    }

    cout<< yes<< endl;
    return 0;
}
0