結果

問題 No.275 中央値を求めよ
ユーザー 14番14番
提出日時 2016-03-27 14:41:21
言語 C#
(csc 3.9.0)
結果
AC  
実行時間 75 ms / 1,000 ms
コード長 1,554 bytes
コンパイル時間 2,815 ms
使用メモリ 17,568 KB
最終ジャッジ日時 2023-01-22 21:02:43
合計ジャッジ時間 8,129 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 66 ms
17,232 KB
testcase_01 AC 65 ms
17,216 KB
testcase_02 AC 65 ms
17,140 KB
testcase_03 AC 65 ms
17,216 KB
testcase_04 AC 65 ms
17,336 KB
testcase_05 AC 65 ms
17,296 KB
testcase_06 AC 66 ms
17,228 KB
testcase_07 AC 74 ms
17,356 KB
testcase_08 AC 72 ms
17,412 KB
testcase_09 AC 73 ms
17,392 KB
testcase_10 AC 72 ms
17,380 KB
testcase_11 AC 62 ms
17,180 KB
testcase_12 AC 63 ms
15,216 KB
testcase_13 AC 62 ms
15,220 KB
testcase_14 AC 63 ms
15,160 KB
testcase_15 AC 73 ms
17,488 KB
testcase_16 AC 73 ms
17,396 KB
testcase_17 AC 73 ms
17,456 KB
testcase_18 AC 72 ms
17,432 KB
testcase_19 AC 73 ms
17,512 KB
testcase_20 AC 73 ms
17,492 KB
testcase_21 AC 72 ms
17,456 KB
testcase_22 AC 73 ms
17,472 KB
testcase_23 AC 73 ms
17,432 KB
testcase_24 AC 72 ms
17,400 KB
testcase_25 AC 74 ms
17,452 KB
testcase_26 AC 75 ms
17,448 KB
testcase_27 AC 73 ms
17,472 KB
testcase_28 AC 65 ms
17,184 KB
testcase_29 AC 73 ms
17,408 KB
testcase_30 AC 65 ms
17,208 KB
testcase_31 AC 73 ms
17,568 KB
testcase_32 AC 72 ms
17,436 KB
testcase_33 AC 72 ms
17,428 KB
testcase_34 AC 65 ms
17,256 KB
testcase_35 AC 74 ms
17,464 KB
testcase_36 AC 73 ms
17,448 KB
testcase_37 AC 74 ms
17,456 KB
testcase_38 AC 74 ms
17,488 KB
testcase_39 AC 73 ms
17,348 KB
testcase_40 AC 73 ms
17,444 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.Text;

public class Program
{
    public void Proc(){
        Reader.IsDebug =  false;
        
        int numCOunt = int.Parse(Reader.ReadLine());
        
        List<int> numList = new List<int>();
        numList.AddRange(Reader.GetInt());
        numList.Sort();
        double ans = numList[0];
        if(numList.Count % 2 == 0 && numList.Count >= 2) {
            int idx1 = numList.Count / 2;
            ans = (numList[idx1 - 1] + numList[idx1]) / 2.0;
        } else
        {
             int idx = numList.Count / 2;
             ans = numList[idx];
        }
        Console.WriteLine(ans.ToString("#################0.0"));

    }

    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}

class Reader
{
    public static bool IsDebug = true;
    
    private static System.IO.StringReader sr;
    
    public static string ReadLine() {
        if(IsDebug) {
            if(sr == null) {
                sr = new System.IO.StringReader(initStr.Trim());
            }
            return sr.ReadLine();
        } else {
            return Console.ReadLine();
        }
    }
    
    public static int[] GetInt(char delimiter = ' ') {
        string[] inpt = ReadLine().Split(delimiter);
        int[] ret = new int[inpt.Length];
        for(int i=0; i<inpt.Length; i++) {
            ret[i] = int.Parse(inpt[i]);
        }
        return ret;
    }
    
    private static string initStr = @"


6
1 2 3 4 5 6

    ";
}

0