結果

問題 No.702 中央値を求めよ LIMITED
ユーザー nebukuro09nebukuro09
提出日時 2018-06-15 22:40:48
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 918 bytes
コンパイル時間 661 ms
コンパイル使用メモリ 99,660 KB
実行使用メモリ 23,824 KB
最終ジャッジ日時 2023-09-03 20:25:50
合計ジャッジ時間 6,513 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 169 ms
22,300 KB
testcase_01 AC 171 ms
22,224 KB
testcase_02 AC 170 ms
22,300 KB
testcase_03 AC 171 ms
22,564 KB
testcase_04 WA -
testcase_05 AC 169 ms
23,296 KB
testcase_06 AC 170 ms
22,824 KB
testcase_07 AC 171 ms
22,600 KB
testcase_08 AC 173 ms
22,800 KB
testcase_09 AC 171 ms
23,324 KB
testcase_10 AC 171 ms
22,536 KB
testcase_11 AC 171 ms
22,524 KB
testcase_12 AC 173 ms
23,524 KB
testcase_13 AC 170 ms
22,292 KB
testcase_14 AC 174 ms
22,272 KB
testcase_15 AC 171 ms
23,824 KB
testcase_16 AC 170 ms
23,592 KB
testcase_17 AC 170 ms
22,600 KB
testcase_18 AC 170 ms
23,276 KB
testcase_19 WA -
testcase_20 AC 171 ms
22,568 KB
testcase_21 WA -
testcase_22 AC 171 ms
22,584 KB
testcase_23 AC 170 ms
22,796 KB
testcase_24 WA -
testcase_25 AC 174 ms
22,320 KB
testcase_26 AC 171 ms
22,508 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^^6 * 5;
    uint seed = readln.chomp.to!uint;
    x = seed;
    int less = 0;
    auto A = new int[](K);
    uint hoge = 2147000000;

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

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