結果

問題 No.702 中央値を求めよ LIMITED
ユーザー bal4ubal4u
提出日時 2019-05-05 17:07:38
言語 C
(gcc 12.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 905 bytes
コンパイル時間 507 ms
コンパイル使用メモリ 29,148 KB
実行使用メモリ 22,412 KB
最終ジャッジ日時 2023-08-07 02:46:29
合計ジャッジ時間 4,037 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
22,284 KB
testcase_01 AC 91 ms
22,288 KB
testcase_02 AC 110 ms
22,316 KB
testcase_03 AC 98 ms
22,292 KB
testcase_04 AC 112 ms
22,240 KB
testcase_05 AC 75 ms
22,320 KB
testcase_06 AC 92 ms
22,284 KB
testcase_07 AC 109 ms
22,240 KB
testcase_08 AC 105 ms
22,276 KB
testcase_09 AC 97 ms
22,204 KB
testcase_10 AC 91 ms
22,380 KB
testcase_11 AC 73 ms
22,296 KB
testcase_12 AC 114 ms
22,272 KB
testcase_13 AC 81 ms
22,204 KB
testcase_14 AC 71 ms
22,376 KB
testcase_15 AC 99 ms
22,328 KB
testcase_16 AC 104 ms
22,288 KB
testcase_17 AC 95 ms
22,300 KB
testcase_18 AC 100 ms
22,292 KB
testcase_19 AC 96 ms
22,380 KB
testcase_20 AC 76 ms
22,208 KB
testcase_21 AC 99 ms
22,308 KB
testcase_22 AC 111 ms
22,296 KB
testcase_23 AC 112 ms
22,320 KB
testcase_24 AC 89 ms
22,232 KB
testcase_25 WA -
testcase_26 AC 92 ms
22,272 KB
権限があれば一括ダウンロードができます

ソースコード

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;
}

unsigned 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 6002000
#define HALF (unsigned)2150000000
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 <= HALF) a[sz++] = k;
	}
	printf("%u\n", selection(a, sz, 5000000));
    return 0;
}
0