結果
| 問題 | No.702 中央値を求めよ LIMITED | 
| コンテスト | |
| ユーザー |  bal4u | 
| 提出日時 | 2019-05-05 17:00:01 | 
| 言語 | C (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 872 bytes | 
| コンパイル時間 | 465 ms | 
| コンパイル使用メモリ | 30,336 KB | 
| 実行使用メモリ | 21,428 KB | 
| 最終ジャッジ日時 | 2024-06-25 05:44:05 | 
| 合計ジャッジ時間 | 5,795 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 WA * 1 | 
| other | AC * 7 WA * 16 RE * 2 | 
ソースコード
// 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;
}
            
            
            
        