結果

問題 No.275 中央値を求めよ
ユーザー yurara
提出日時 2019-04-09 21:44:37
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 39 ms / 1,000 ms
コード長 487 bytes
コンパイル時間 4,155 ms
コンパイル使用メモリ 105,984 KB
実行使用メモリ 20,608 KB
最終ジャッジ日時 2024-07-05 02:40:08
合計ジャッジ時間 5,084 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Linq;

public class Program
{
    public static void Main()
    {
        _ = Console.ReadLine();
        var lst = Console.ReadLine().Split(' ').
                        Select(s => int.Parse(s)).ToList();
        var ct = lst.Count;

        lst.Sort();

        if (ct % 2 == 0)
            Console.Write("{0}", ((lst[ct / 2 -1] + lst[ct / 2])/2.0).ToString());
        else
            Console.Write("{0}", lst[ct / 2].ToString());

        return;
    }
}
0