結果

問題 No.275 中央値を求めよ
ユーザー 14番14番
提出日時 2016-03-27 14:41:21
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 84 ms / 1,000 ms
コード長 1,554 bytes
コンパイル時間 3,619 ms
コンパイル使用メモリ 105,012 KB
実行使用メモリ 25,508 KB
最終ジャッジ日時 2023-09-07 05:17:54
合計ジャッジ時間 7,455 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
23,132 KB
testcase_01 AC 69 ms
25,192 KB
testcase_02 AC 69 ms
23,176 KB
testcase_03 AC 68 ms
23,172 KB
testcase_04 AC 68 ms
23,132 KB
testcase_05 AC 69 ms
25,220 KB
testcase_06 AC 70 ms
25,152 KB
testcase_07 AC 80 ms
23,236 KB
testcase_08 AC 77 ms
23,356 KB
testcase_09 AC 76 ms
25,364 KB
testcase_10 AC 77 ms
25,260 KB
testcase_11 AC 69 ms
23,160 KB
testcase_12 AC 68 ms
23,240 KB
testcase_13 AC 70 ms
21,100 KB
testcase_14 AC 68 ms
21,244 KB
testcase_15 AC 79 ms
23,268 KB
testcase_16 AC 80 ms
23,364 KB
testcase_17 AC 78 ms
23,256 KB
testcase_18 AC 78 ms
23,396 KB
testcase_19 AC 81 ms
23,356 KB
testcase_20 AC 79 ms
23,452 KB
testcase_21 AC 79 ms
25,396 KB
testcase_22 AC 79 ms
23,360 KB
testcase_23 AC 84 ms
23,292 KB
testcase_24 AC 84 ms
25,420 KB
testcase_25 AC 79 ms
23,380 KB
testcase_26 AC 82 ms
23,356 KB
testcase_27 AC 78 ms
23,348 KB
testcase_28 AC 70 ms
25,072 KB
testcase_29 AC 81 ms
21,248 KB
testcase_30 AC 71 ms
23,216 KB
testcase_31 AC 77 ms
25,508 KB
testcase_32 AC 78 ms
25,472 KB
testcase_33 AC 79 ms
23,388 KB
testcase_34 AC 69 ms
25,196 KB
testcase_35 AC 78 ms
23,300 KB
testcase_36 AC 78 ms
23,456 KB
testcase_37 AC 76 ms
23,260 KB
testcase_38 AC 76 ms
25,348 KB
testcase_39 AC 77 ms
23,312 KB
testcase_40 AC 76 ms
23,260 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