結果

問題 No.702 中央値を求めよ LIMITED
ユーザー mbanmban
提出日時 2018-06-15 23:03:59
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 233 ms / 5,000 ms
コード長 2,761 bytes
コンパイル時間 2,888 ms
コンパイル使用メモリ 102,224 KB
実行使用メモリ 24,356 KB
最終ジャッジ日時 2023-08-14 21:12:01
合計ジャッジ時間 10,229 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 223 ms
24,356 KB
testcase_01 AC 222 ms
22,292 KB
testcase_02 AC 221 ms
22,116 KB
testcase_03 AC 222 ms
22,240 KB
testcase_04 AC 224 ms
22,132 KB
testcase_05 AC 223 ms
24,108 KB
testcase_06 AC 231 ms
22,144 KB
testcase_07 AC 222 ms
24,168 KB
testcase_08 AC 217 ms
22,144 KB
testcase_09 AC 218 ms
20,108 KB
testcase_10 AC 220 ms
24,224 KB
testcase_11 AC 224 ms
22,132 KB
testcase_12 AC 222 ms
22,320 KB
testcase_13 AC 226 ms
24,160 KB
testcase_14 AC 229 ms
24,120 KB
testcase_15 AC 233 ms
24,240 KB
testcase_16 AC 232 ms
22,072 KB
testcase_17 AC 222 ms
22,120 KB
testcase_18 AC 230 ms
22,128 KB
testcase_19 AC 227 ms
22,116 KB
testcase_20 AC 224 ms
24,252 KB
testcase_21 AC 219 ms
22,192 KB
testcase_22 AC 225 ms
22,224 KB
testcase_23 AC 221 ms
22,172 KB
testcase_24 AC 229 ms
24,144 KB
testcase_25 AC 223 ms
20,024 KB
testcase_26 AC 226 ms
22,828 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;
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;
            uint max = (uint)int.MaxValue + 50000000;
            int Cnt = 0;
            List<uint> l = new List<uint>();
            for (int i = 0; i < length; i++)
            {
                var u = Generate();
                if (max < u) continue;
                if (min > u)
                {
                    Cnt++;
                }
                else
                {
                    l.Add(u);
                }
            }
            l.Sort();
            Console.WriteLine(l[length / 2 - Cnt]);
        }

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

}
0