結果

問題 No.275 中央値を求めよ
ユーザー NoNo
提出日時 2015-11-03 23:52:54
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 78 ms / 1,000 ms
コード長 834 bytes
コンパイル時間 4,214 ms
コンパイル使用メモリ 103,420 KB
実行使用メモリ 24,804 KB
最終ジャッジ日時 2023-09-07 04:58:11
合計ジャッジ時間 6,756 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
22,620 KB
testcase_01 AC 65 ms
22,624 KB
testcase_02 AC 65 ms
24,532 KB
testcase_03 AC 65 ms
22,580 KB
testcase_04 AC 70 ms
24,620 KB
testcase_05 AC 73 ms
22,660 KB
testcase_06 AC 65 ms
22,656 KB
testcase_07 AC 77 ms
22,616 KB
testcase_08 AC 72 ms
22,624 KB
testcase_09 AC 75 ms
22,712 KB
testcase_10 AC 73 ms
24,652 KB
testcase_11 AC 63 ms
24,652 KB
testcase_12 AC 64 ms
20,704 KB
testcase_13 AC 61 ms
18,684 KB
testcase_14 AC 61 ms
20,600 KB
testcase_15 AC 74 ms
24,644 KB
testcase_16 AC 75 ms
22,632 KB
testcase_17 AC 75 ms
22,824 KB
testcase_18 AC 74 ms
24,732 KB
testcase_19 AC 73 ms
22,676 KB
testcase_20 AC 73 ms
22,736 KB
testcase_21 AC 72 ms
20,732 KB
testcase_22 AC 73 ms
24,716 KB
testcase_23 AC 72 ms
20,764 KB
testcase_24 AC 72 ms
22,740 KB
testcase_25 AC 73 ms
24,732 KB
testcase_26 AC 74 ms
22,692 KB
testcase_27 AC 73 ms
22,636 KB
testcase_28 AC 66 ms
24,596 KB
testcase_29 AC 74 ms
24,752 KB
testcase_30 AC 65 ms
22,504 KB
testcase_31 AC 72 ms
22,888 KB
testcase_32 AC 71 ms
24,732 KB
testcase_33 AC 73 ms
20,744 KB
testcase_34 AC 65 ms
20,620 KB
testcase_35 AC 73 ms
22,644 KB
testcase_36 AC 78 ms
24,804 KB
testcase_37 AC 77 ms
22,728 KB
testcase_38 AC 74 ms
24,672 KB
testcase_39 AC 74 ms
24,716 KB
testcase_40 AC 73 ms
22,576 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.Threading.Tasks;

namespace Yuki
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var li = ConvertStringArrayToIntList(Console.ReadLine().Split());
            double ans = 0;

            li.Sort();

            if (N % 2 == 0)
            {
                ans = (li[N / 2 - 1] + li[N / 2]) / 2d;
            }else
            {
                ans = li[N / 2];
            } 

            Console.WriteLine(ans);
        }

        static List<int> ConvertStringArrayToIntList(string[] str)
        {
            var list = new List<int>();
            foreach (var c in str) list.Add(int.Parse(c));
            return list;
        }
    }
}
0