結果

問題 No.702 中央値を求めよ LIMITED
ユーザー mamekinmamekin
提出日時 2018-10-06 20:51:43
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 5,000 ms
コード長 1,371 bytes
コンパイル時間 990 ms
コンパイル使用メモリ 101,576 KB
実行使用メモリ 27,896 KB
最終ジャッジ日時 2023-08-14 21:44:59
合計ジャッジ時間 3,326 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
27,644 KB
testcase_01 AC 39 ms
27,596 KB
testcase_02 AC 38 ms
27,540 KB
testcase_03 AC 39 ms
27,588 KB
testcase_04 AC 38 ms
27,708 KB
testcase_05 AC 38 ms
27,896 KB
testcase_06 AC 39 ms
27,700 KB
testcase_07 AC 39 ms
27,716 KB
testcase_08 AC 40 ms
27,660 KB
testcase_09 AC 39 ms
27,640 KB
testcase_10 AC 39 ms
27,872 KB
testcase_11 AC 40 ms
27,640 KB
testcase_12 AC 40 ms
27,708 KB
testcase_13 AC 39 ms
27,596 KB
testcase_14 AC 41 ms
27,644 KB
testcase_15 AC 40 ms
27,704 KB
testcase_16 AC 40 ms
27,656 KB
testcase_17 AC 39 ms
27,536 KB
testcase_18 AC 39 ms
27,588 KB
testcase_19 AC 38 ms
27,632 KB
testcase_20 AC 39 ms
27,764 KB
testcase_21 AC 39 ms
27,852 KB
testcase_22 AC 38 ms
27,700 KB
testcase_23 AC 39 ms
27,580 KB
testcase_24 AC 37 ms
27,640 KB
testcase_25 AC 41 ms
27,704 KB
testcase_26 AC 39 ms
27,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class Xorshift
{
private:
    uint32_t x, y, z, w;
public:
    Xorshift(uint32_t seed){
        x = seed;
        y = 1;
        z = 2;
        w = 3;
    }
    uint32_t operator()(){
        uint32_t t=(x^(x<<11));
        x=y; y=z; z=w;
        return w=(w^(w>>19))^(t^(t>>8));
    }
};

const unsigned MID = 0x80000000;
const int LEN = 0x300000;

int main()
{
    int seed;
    cin >> seed;
    Xorshift xorshift(seed);

    int n = 10000001;
    vector<int> cnt(LEN*2+1);
    for(int i=0; i<n; ++i){
        long long a = xorshift();
        a -= MID;
        if(a < -LEN)
            a = -LEN;
        else if(a > LEN)
            a = LEN;
        ++ cnt[(unsigned)a+LEN];
    }

    int a = 0;
    int tmp = 0;
    for(;;){
        tmp += cnt[a];
        if(tmp > n / 2)
            break;
        ++ a;
    }

    long long ans = a;
    ans += MID - LEN;
    cout << ans << endl;

    return 0;
}
0