結果

問題 No.702 中央値を求めよ LIMITED
ユーザー ldsybldsyb
提出日時 2018-06-16 16:41:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 713 ms / 5,000 ms
コード長 708 bytes
コンパイル時間 1,656 ms
コンパイル使用メモリ 166,296 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-02 09:37:26
合計ジャッジ時間 20,790 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 653 ms
5,248 KB
testcase_01 AC 665 ms
5,376 KB
testcase_02 AC 677 ms
5,376 KB
testcase_03 AC 684 ms
5,376 KB
testcase_04 AC 684 ms
5,376 KB
testcase_05 AC 678 ms
5,376 KB
testcase_06 AC 657 ms
5,376 KB
testcase_07 AC 656 ms
5,376 KB
testcase_08 AC 679 ms
5,376 KB
testcase_09 AC 656 ms
5,376 KB
testcase_10 AC 662 ms
5,376 KB
testcase_11 AC 656 ms
5,376 KB
testcase_12 AC 665 ms
5,376 KB
testcase_13 AC 663 ms
5,376 KB
testcase_14 AC 679 ms
5,376 KB
testcase_15 AC 667 ms
5,376 KB
testcase_16 AC 665 ms
5,376 KB
testcase_17 AC 649 ms
5,376 KB
testcase_18 AC 654 ms
5,376 KB
testcase_19 AC 657 ms
5,376 KB
testcase_20 AC 673 ms
5,376 KB
testcase_21 AC 654 ms
5,376 KB
testcase_22 AC 652 ms
5,376 KB
testcase_23 AC 713 ms
5,376 KB
testcase_24 AC 694 ms
5,376 KB
testcase_25 AC 695 ms
5,376 KB
testcase_26 AC 661 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
	struct generate
	{
		uint32_t x = 0, y = 1, z = 2, w = 3, seed;

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

		uint32_t operator()()
		{
			uint32_t t = (x ^ (x << 11));
			x = y;
			y = z;
			z = w;
			w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
			return w;
		}
	} g;

	int64_t seed, n = 10000000;
	cin >> seed;
	g.seed = seed;

	int64_t l = 0, r = (1ll << 40);
	while (1 < r - l)
	{
		int64_t mid = (l + r) / 2;
		int count = 0;
		g.reset();
		for (int i = 0; i <= n; i++)
		{
			if (g() <= mid)
			{
				count++;
			}
		}
		if (2 * count <= n)
		{
			l = mid;
		}
		else
		{
			r = mid;
		}
	}
	cout << r << endl;
	return 0;
}
0