結果

問題 No.702 中央値を求めよ LIMITED
ユーザー bal4ubal4u
提出日時 2019-05-05 17:00:01
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 872 bytes
コンパイル時間 993 ms
コンパイル使用メモリ 29,128 KB
実行使用メモリ 21,464 KB
最終ジャッジ日時 2023-09-07 11:34:53
合計ジャッジ時間 6,761 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
21,332 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 RE -
testcase_05 AC 108 ms
21,312 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 85 ms
21,248 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 93 ms
21,328 KB
testcase_18 WA -
testcase_19 AC 101 ms
21,388 KB
testcase_20 WA -
testcase_21 AC 114 ms
21,356 KB
testcase_22 AC 85 ms
21,316 KB
testcase_23 AC 71 ms
21,424 KB
testcase_24 RE -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder: No. 702 中央値を求めよ LIMITED
// 2019.5.5 bal4u

#include <stdio.h>

unsigned x = 0, y = 1, z = 2, w = 3;
unsigned generate() { 
    unsigned t = x^(x<<11);
    x = y, y = z, z = w;
    w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
    return w;
}

int selection(unsigned *a, int sz, int n) {
	int i, j, l, r;
	unsigned p, t;
	l = 0, r = sz-1;
	while (l < r) {
		p = a[(l+r)/2];
		i = l-1, j = r+1;
		while (1) {
			while (a[++i] < p);
			while (a[--j] > p);
			if (i > j) break;
			t = a[i], a[i] = a[j], a[j] = t;
		}
		if (n < i) r = j;
		if (n > j) l = i;
	}
	return a[n];
}


#define H 5002000
unsigned a[H+100]; int sz;

int main()
 {
    int i, seed;
	unsigned k;

	scanf("%d", &seed); 
    x = seed;
	for (i = 0; i < 10000001; i++) {
		k = generate();
		if (k <= 2147483648) a[sz++] = k;
	}
	printf("%d\n", selection(a, sz, 5000000));
    return 0;
}
0