結果

問題 No.702 中央値を求めよ LIMITED
ユーザー antaanta
提出日時 2018-06-15 22:30:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 675 bytes
コンパイル時間 1,567 ms
コンパイル使用メモリ 165,744 KB
実行使用メモリ 11,504 KB
最終ジャッジ日時 2023-08-03 07:01:06
合計ジャッジ時間 5,430 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
11,324 KB
testcase_01 AC 64 ms
11,268 KB
testcase_02 AC 63 ms
11,244 KB
testcase_03 AC 63 ms
11,272 KB
testcase_04 AC 62 ms
11,324 KB
testcase_05 AC 63 ms
11,276 KB
testcase_06 AC 64 ms
11,248 KB
testcase_07 AC 65 ms
11,300 KB
testcase_08 AC 65 ms
11,328 KB
testcase_09 AC 65 ms
11,268 KB
testcase_10 AC 64 ms
11,252 KB
testcase_11 AC 65 ms
11,256 KB
testcase_12 AC 66 ms
11,504 KB
testcase_13 AC 63 ms
11,320 KB
testcase_14 WA -
testcase_15 AC 64 ms
11,300 KB
testcase_16 AC 62 ms
11,208 KB
testcase_17 AC 62 ms
11,324 KB
testcase_18 AC 63 ms
11,296 KB
testcase_19 AC 62 ms
11,252 KB
testcase_20 AC 65 ms
11,380 KB
testcase_21 AC 63 ms
11,304 KB
testcase_22 AC 63 ms
11,444 KB
testcase_23 AC 64 ms
11,276 KB
testcase_24 AC 60 ms
11,272 KB
testcase_25 WA -
testcase_26 AC 63 ms
11,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.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() {
	int seed;
	while (~scanf("%d", &seed)) {
		x = seed, y = 1, z = 2, w = 3;
		int n = 10000001, k = 1U << 21;
		auto mid = 1U << 31;
		vector<int16_t> cnt(k * 2 + 1);
		int L = 0;
		for (int i = 0; i < n; i++) {
			auto x = generate();
			if (x < mid - k)
				++ L;
			else if(x <= mid + k)
				++ cnt[x + k - mid];
		}
		for (int d = -k; d <= k; ++ d) {
			L += cnt[k + d];
			if (L > n / 2) {
				printf("%u\n", mid + d);
				break;
			}
		}
	}
}
0