結果

問題 No.702 中央値を求めよ LIMITED
ユーザー AreTrashAreTrash
提出日時 2018-10-12 10:31:22
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 241 ms / 5,000 ms
コード長 1,159 bytes
コンパイル時間 2,303 ms
コンパイル使用メモリ 104,648 KB
実行使用メモリ 24,728 KB
最終ジャッジ日時 2023-08-14 21:48:25
合計ジャッジ時間 10,118 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 235 ms
22,276 KB
testcase_01 AC 239 ms
22,716 KB
testcase_02 AC 240 ms
22,788 KB
testcase_03 AC 238 ms
22,308 KB
testcase_04 AC 240 ms
24,300 KB
testcase_05 AC 239 ms
21,076 KB
testcase_06 AC 239 ms
21,020 KB
testcase_07 AC 239 ms
20,308 KB
testcase_08 AC 240 ms
22,268 KB
testcase_09 AC 241 ms
24,268 KB
testcase_10 AC 240 ms
22,496 KB
testcase_11 AC 240 ms
23,080 KB
testcase_12 AC 241 ms
21,008 KB
testcase_13 AC 240 ms
22,244 KB
testcase_14 AC 240 ms
22,252 KB
testcase_15 AC 239 ms
24,728 KB
testcase_16 AC 240 ms
20,988 KB
testcase_17 AC 241 ms
21,028 KB
testcase_18 AC 240 ms
20,260 KB
testcase_19 AC 241 ms
24,304 KB
testcase_20 AC 240 ms
21,064 KB
testcase_21 AC 241 ms
24,340 KB
testcase_22 AC 240 ms
20,980 KB
testcase_23 AC 241 ms
24,304 KB
testcase_24 AC 240 ms
24,412 KB
testcase_25 AC 241 ms
24,408 KB
testcase_26 AC 240 ms
22,264 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;

namespace No702
{
    public class Program
    {
        public static void Main(string[] args)
        {
            const int A = 10000001;
            const uint Min = 2100000000;
            const uint Max = 2200000000;

            var seed = uint.Parse(Console.ReadLine());
            var xorShift = new XorShift(seed);
            var list = new List<uint>(A + 10);
            var offset = 0;

            for (var i = 0; i < A; i++)
            {
                var gen = xorShift.Generate();
                if (gen < Min) offset++;
                if (gen < Min || Max < gen) continue;
                list.Add(gen);
            }

            list.Sort();
            Console.WriteLine(list[A / 2 - offset]);
        }
    }

    public class XorShift
    {
        uint x = 0, y = 1, z = 2, w = 3;

        public XorShift(uint seed)
        {
            x = seed;
        }

        public uint Generate()
        {
            var t = x ^ (x << 11);
            x = y;
            y = z;
            z = w;
            w = w ^ (w >> 19) ^ t ^ (t >> 8);
            return w;
        }
    }
}
0