結果

問題 No.702 中央値を求めよ LIMITED
ユーザー mbanmban
提出日時 2018-06-15 23:01:14
言語 C#(csc)
(csc 3.9.0)
結果
MLE  
実行時間 -
コード長 2,668 bytes
コンパイル時間 2,294 ms
コンパイル使用メモリ 104,932 KB
実行使用メモリ 75,852 KB
最終ジャッジ日時 2023-09-13 05:11:33
合計ジャッジ時間 58,078 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 MLE -
testcase_02 MLE -
testcase_03 MLE -
testcase_04 MLE -
testcase_05 MLE -
testcase_06 MLE -
testcase_07 MLE -
testcase_08 MLE -
testcase_09 MLE -
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 MLE -
testcase_20 MLE -
testcase_21 MLE -
testcase_22 MLE -
testcase_23 MLE -
testcase_24 MLE -
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.Remoting.Contexts;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }

        public uint NextUint()
        {
            return uint.Parse(Next());
        }
    }

    class Program
    {
        private uint Seed;
        private uint x = 0, y = 1, z = 2, w = 3;
        private void Scan()
        {
            var sc = new Scanner();
            Seed = sc.NextUint();

        }

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

        }


        public void Solve()
        {
            Scan();
            x = Seed;
            int length = 10000001;
            uint min = int.MaxValue - 50000000;
            int Cnt = 0;
            List<uint> l = new List<uint>();
            for (int i = 0; i < length; i++)
            {
                var u = Generate();
                if (min > u)
                {
                    Cnt++;
                }
                else
                {
                    l.Add(u);
                }
            }
            l.Sort();
            Console.WriteLine(l[length / 2 - Cnt]);
        }

        static void Main() => new Program().Solve();
    }

}
0