結果

問題 No.275 中央値を求めよ
ユーザー poritporit
提出日時 2017-08-16 21:49:21
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 79 ms / 1,000 ms
コード長 960 bytes
コンパイル時間 2,124 ms
コンパイル使用メモリ 104,636 KB
実行使用メモリ 24,832 KB
最終ジャッジ日時 2023-09-07 06:12:51
合計ジャッジ時間 6,715 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
22,628 KB
testcase_01 AC 67 ms
24,620 KB
testcase_02 AC 69 ms
22,616 KB
testcase_03 AC 67 ms
22,648 KB
testcase_04 AC 67 ms
22,544 KB
testcase_05 AC 68 ms
22,604 KB
testcase_06 AC 69 ms
22,760 KB
testcase_07 AC 76 ms
22,660 KB
testcase_08 AC 75 ms
20,784 KB
testcase_09 AC 76 ms
24,832 KB
testcase_10 AC 75 ms
22,960 KB
testcase_11 AC 66 ms
22,740 KB
testcase_12 AC 65 ms
22,732 KB
testcase_13 AC 64 ms
20,588 KB
testcase_14 AC 64 ms
20,552 KB
testcase_15 AC 76 ms
24,708 KB
testcase_16 AC 76 ms
22,844 KB
testcase_17 AC 78 ms
20,876 KB
testcase_18 AC 76 ms
20,828 KB
testcase_19 AC 77 ms
22,764 KB
testcase_20 AC 76 ms
22,676 KB
testcase_21 AC 77 ms
22,776 KB
testcase_22 AC 76 ms
22,684 KB
testcase_23 AC 77 ms
22,996 KB
testcase_24 AC 76 ms
22,932 KB
testcase_25 AC 77 ms
22,780 KB
testcase_26 AC 77 ms
20,748 KB
testcase_27 AC 77 ms
22,880 KB
testcase_28 AC 69 ms
22,448 KB
testcase_29 AC 76 ms
22,624 KB
testcase_30 AC 68 ms
22,920 KB
testcase_31 AC 77 ms
22,812 KB
testcase_32 AC 76 ms
23,056 KB
testcase_33 AC 76 ms
20,824 KB
testcase_34 AC 68 ms
22,628 KB
testcase_35 AC 77 ms
23,028 KB
testcase_36 AC 79 ms
20,732 KB
testcase_37 AC 75 ms
22,828 KB
testcase_38 AC 77 ms
20,904 KB
testcase_39 AC 76 ms
22,828 KB
testcase_40 AC 76 ms
22,660 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 ConsoleApp19
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] numArray = Console.ReadLine().Split(' ');
            double[] array = new double[numArray.Length];
            double result = 0;

            for (int i = 0; i < numArray.Length; i++)
            {
                array[i] = double.Parse(numArray[i]);
            }

            Array.Sort(array);

            if (n % 2 != 0)
            {
                result = array[n/2];

            }
            else if (n % 2 == 0)
            {
                double a = array[n / 2];
                double b = array[(n / 2)- 1];
                result = (a + b) / 2;
            }


            Console.WriteLine(result);
            Console.ReadLine();
        }
    }
}
0