結果

問題 No.702 中央値を求めよ LIMITED
ユーザー nebukuro09nebukuro09
提出日時 2018-06-15 22:43:25
言語 D
(dmd 2.105.2)
結果
AC  
実行時間 206 ms / 5,000 ms
コード長 903 bytes
コンパイル時間 572 ms
コンパイル使用メモリ 104,772 KB
実行使用メモリ 5,396 KB
最終ジャッジ日時 2023-09-03 20:26:07
合計ジャッジ時間 6,931 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 184 ms
5,132 KB
testcase_01 AC 185 ms
4,376 KB
testcase_02 AC 181 ms
4,380 KB
testcase_03 AC 187 ms
4,376 KB
testcase_04 AC 186 ms
4,376 KB
testcase_05 AC 206 ms
5,376 KB
testcase_06 AC 190 ms
4,380 KB
testcase_07 AC 184 ms
4,376 KB
testcase_08 AC 184 ms
4,376 KB
testcase_09 AC 183 ms
5,080 KB
testcase_10 AC 185 ms
4,376 KB
testcase_11 AC 185 ms
4,384 KB
testcase_12 AC 183 ms
4,376 KB
testcase_13 AC 182 ms
4,380 KB
testcase_14 AC 187 ms
4,384 KB
testcase_15 AC 187 ms
4,376 KB
testcase_16 AC 187 ms
4,376 KB
testcase_17 AC 190 ms
4,380 KB
testcase_18 AC 183 ms
4,384 KB
testcase_19 AC 185 ms
4,380 KB
testcase_20 AC 200 ms
5,396 KB
testcase_21 AC 187 ms
5,140 KB
testcase_22 AC 194 ms
4,384 KB
testcase_23 AC 183 ms
4,380 KB
testcase_24 AC 188 ms
4,376 KB
testcase_25 AC 184 ms
4,380 KB
testcase_26 AC 182 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

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

void main() {
    int N = 10000001;
    int M = N / 2 + 1;
    int K = 10^^8;
    uint seed = readln.chomp.to!uint;
    x = seed;
    int less = 0;
    uint hoge = 2140000000;
    uint[] A;

    foreach (_; 0..N) {
        uint a = generate();
        if (a >= hoge && a < hoge + K)
            A ~= a;
        else if (a < hoge)
            less += 1;
    }

    A.sort();

    foreach (i; 0..A.length) {
        if (less + 1 >= M) {
            writeln(A[i]);
            return;
        } else {
            less += 1;
        }
    }
}
0