結果

問題 No.702 中央値を求めよ LIMITED
ユーザー antaanta
提出日時 2018-06-15 22:30:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 675 bytes
コンパイル時間 1,999 ms
コンパイル使用メモリ 165,664 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-04-21 06:03:09
合計ジャッジ時間 4,228 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
11,648 KB
testcase_01 AC 71 ms
11,504 KB
testcase_02 AC 71 ms
11,520 KB
testcase_03 AC 67 ms
11,568 KB
testcase_04 AC 65 ms
11,392 KB
testcase_05 AC 67 ms
11,520 KB
testcase_06 AC 69 ms
11,520 KB
testcase_07 AC 68 ms
11,496 KB
testcase_08 AC 67 ms
11,520 KB
testcase_09 AC 68 ms
11,520 KB
testcase_10 AC 67 ms
11,604 KB
testcase_11 AC 68 ms
11,648 KB
testcase_12 AC 70 ms
11,512 KB
testcase_13 AC 67 ms
11,520 KB
testcase_14 WA -
testcase_15 AC 67 ms
11,520 KB
testcase_16 AC 67 ms
11,520 KB
testcase_17 AC 66 ms
11,620 KB
testcase_18 AC 68 ms
11,520 KB
testcase_19 AC 68 ms
11,520 KB
testcase_20 AC 71 ms
11,520 KB
testcase_21 AC 70 ms
11,520 KB
testcase_22 AC 70 ms
11,520 KB
testcase_23 AC 69 ms
11,520 KB
testcase_24 AC 67 ms
11,520 KB
testcase_25 WA -
testcase_26 AC 67 ms
11,648 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