結果

問題 No.702 中央値を求めよ LIMITED
ユーザー antaanta
提出日時 2018-06-15 22:29:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 671 bytes
コンパイル時間 1,426 ms
コンパイル使用メモリ 164,396 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2023-09-13 04:49:41
合計ジャッジ時間 4,538 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
11,216 KB
testcase_01 AC 62 ms
11,192 KB
testcase_02 AC 62 ms
11,252 KB
testcase_03 AC 63 ms
11,248 KB
testcase_04 WA -
testcase_05 AC 62 ms
11,256 KB
testcase_06 AC 62 ms
11,300 KB
testcase_07 AC 63 ms
11,288 KB
testcase_08 AC 63 ms
11,240 KB
testcase_09 AC 62 ms
11,292 KB
testcase_10 AC 63 ms
11,364 KB
testcase_11 AC 63 ms
11,292 KB
testcase_12 WA -
testcase_13 AC 62 ms
11,244 KB
testcase_14 WA -
testcase_15 AC 62 ms
11,256 KB
testcase_16 AC 62 ms
11,284 KB
testcase_17 AC 62 ms
11,364 KB
testcase_18 AC 62 ms
11,244 KB
testcase_19 AC 62 ms
11,364 KB
testcase_20 AC 63 ms
11,256 KB
testcase_21 AC 62 ms
11,368 KB
testcase_22 AC 62 ms
11,296 KB
testcase_23 AC 62 ms
11,244 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 63 ms
11,244 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 << 20;
		auto mid = 1U << 31;
		vector<int> 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