結果

問題 No.702 中央値を求めよ LIMITED
ユーザー treeonetreeone
提出日時 2018-07-26 23:41:18
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,241 ms / 5,000 ms
コード長 1,088 bytes
コンパイル時間 1,381 ms
コンパイル使用メモリ 164,384 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-14 21:41:24
合計ジャッジ時間 61,992 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,038 ms
4,376 KB
testcase_01 AC 2,175 ms
4,376 KB
testcase_02 AC 2,039 ms
4,376 KB
testcase_03 AC 2,106 ms
4,380 KB
testcase_04 AC 2,180 ms
4,380 KB
testcase_05 AC 2,170 ms
4,376 KB
testcase_06 AC 2,239 ms
4,376 KB
testcase_07 AC 2,171 ms
4,376 KB
testcase_08 AC 2,172 ms
4,380 KB
testcase_09 AC 2,102 ms
4,380 KB
testcase_10 AC 2,172 ms
4,380 KB
testcase_11 AC 2,172 ms
4,380 KB
testcase_12 AC 2,039 ms
4,376 KB
testcase_13 AC 2,174 ms
4,380 KB
testcase_14 AC 2,172 ms
4,380 KB
testcase_15 AC 2,172 ms
4,376 KB
testcase_16 AC 2,170 ms
4,380 KB
testcase_17 AC 2,103 ms
4,376 KB
testcase_18 AC 2,171 ms
4,376 KB
testcase_19 AC 2,241 ms
4,376 KB
testcase_20 AC 2,105 ms
4,376 KB
testcase_21 AC 2,172 ms
4,376 KB
testcase_22 AC 1,833 ms
4,376 KB
testcase_23 AC 1,903 ms
4,380 KB
testcase_24 AC 2,107 ms
4,380 KB
testcase_25 AC 2,171 ms
4,376 KB
testcase_26 AC 2,177 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
const int INF = 1e15;
const int MAX = 100010;

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;
}

signed main(){
    int n = 10000001;
    int64_t seed; cin >> seed; 
    x = seed;
    // uint32_t a[10000001];
    int l = 0, r = 1e10, ans = -1;
    // for (int i = 0; i < n; i++) {
    //     a[i] = generate();
    //     cout << a[i] << endl;
    // }
    int idx = (n + 1) / 2;
    while(1){
        int m = (l + r) / 2;
        int less = 0, eq = 0;
        x = seed; y = 1, z = 2, w = 3;
        rep(i, 0, n){
            int tmp = generate();
            if(tmp < m) less++;
            else if(tmp == m) eq++;
        }
        // cout << m << ' ' << less << ' ' << eq << endl;
        if(less >= idx) r = m;
        else if(less + eq < idx) l = m;
        else{
            ans = m; break;
        }
    }
    cout << ans << endl;
}
0