結果

問題 No.702 中央値を求めよ LIMITED
ユーザー hirokazu1020hirokazu1020
提出日時 2018-06-15 22:40:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 735 ms / 5,000 ms
コード長 1,127 bytes
コンパイル時間 737 ms
コンパイル使用メモリ 91,788 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-14 21:07:09
合計ジャッジ時間 22,131 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 717 ms
4,380 KB
testcase_01 AC 720 ms
4,380 KB
testcase_02 AC 725 ms
4,380 KB
testcase_03 AC 725 ms
4,380 KB
testcase_04 AC 717 ms
4,384 KB
testcase_05 AC 723 ms
4,376 KB
testcase_06 AC 696 ms
4,380 KB
testcase_07 AC 690 ms
4,380 KB
testcase_08 AC 684 ms
4,380 KB
testcase_09 AC 689 ms
4,376 KB
testcase_10 AC 715 ms
4,380 KB
testcase_11 AC 704 ms
4,380 KB
testcase_12 AC 710 ms
4,380 KB
testcase_13 AC 722 ms
4,384 KB
testcase_14 AC 717 ms
4,376 KB
testcase_15 AC 720 ms
4,384 KB
testcase_16 AC 720 ms
4,380 KB
testcase_17 AC 720 ms
4,380 KB
testcase_18 AC 721 ms
4,376 KB
testcase_19 AC 709 ms
4,376 KB
testcase_20 AC 723 ms
4,380 KB
testcase_21 AC 723 ms
4,380 KB
testcase_22 AC 727 ms
4,380 KB
testcase_23 AC 728 ms
4,376 KB
testcase_24 AC 735 ms
4,376 KB
testcase_25 AC 732 ms
4,380 KB
testcase_26 AC 733 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

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

void init(uint32_t seed) {
	x = seed;
	y = 1;
	z = 2;
	w = 3;
}


int main(void) {
	uint32_t seed; cin >> seed;
	

	uint32_t ans = 0;
	const int n = 10000001;

	rep(i,32) {
		uint32_t mask = ans | 1 << (32 - i - 1);
		int cnt = 0;
		init(seed);
		rep(j, n) {
			cnt += generate() >= mask;
		}
		if (cnt >= (n+1) / 2)ans = mask;
	}

	cout << ans << endl;
	
	return 0;
}
0