結果

問題 No.275 中央値を求めよ
ユーザー _mi_lin__mi_lin_
提出日時 2019-04-04 11:21:23
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 73 ms / 1,000 ms
コード長 1,184 bytes
コンパイル時間 1,969 ms
コンパイル使用メモリ 104,356 KB
実行使用メモリ 24,832 KB
最終ジャッジ日時 2023-08-26 17:10:27
合計ジャッジ時間 6,382 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
24,680 KB
testcase_01 AC 61 ms
24,760 KB
testcase_02 AC 62 ms
22,684 KB
testcase_03 AC 61 ms
22,556 KB
testcase_04 AC 62 ms
24,632 KB
testcase_05 AC 60 ms
22,532 KB
testcase_06 AC 61 ms
22,624 KB
testcase_07 AC 68 ms
20,696 KB
testcase_08 AC 72 ms
22,624 KB
testcase_09 AC 71 ms
22,816 KB
testcase_10 AC 71 ms
22,692 KB
testcase_11 AC 61 ms
22,616 KB
testcase_12 AC 60 ms
22,840 KB
testcase_13 AC 58 ms
20,616 KB
testcase_14 AC 56 ms
20,700 KB
testcase_15 AC 68 ms
22,880 KB
testcase_16 AC 70 ms
24,692 KB
testcase_17 AC 70 ms
22,812 KB
testcase_18 AC 67 ms
22,932 KB
testcase_19 AC 67 ms
22,716 KB
testcase_20 AC 67 ms
24,768 KB
testcase_21 AC 68 ms
24,720 KB
testcase_22 AC 70 ms
22,736 KB
testcase_23 AC 68 ms
24,832 KB
testcase_24 AC 68 ms
22,700 KB
testcase_25 AC 66 ms
22,696 KB
testcase_26 AC 66 ms
24,692 KB
testcase_27 AC 68 ms
22,640 KB
testcase_28 AC 61 ms
22,592 KB
testcase_29 AC 68 ms
22,704 KB
testcase_30 AC 63 ms
22,736 KB
testcase_31 AC 70 ms
24,772 KB
testcase_32 AC 70 ms
22,840 KB
testcase_33 AC 70 ms
22,816 KB
testcase_34 AC 61 ms
22,668 KB
testcase_35 AC 68 ms
22,572 KB
testcase_36 AC 68 ms
24,764 KB
testcase_37 AC 67 ms
22,756 KB
testcase_38 AC 66 ms
24,808 KB
testcase_39 AC 73 ms
22,844 KB
testcase_40 AC 73 ms
24,736 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 No275median
{
    class Program
    {
        static void Main(string[] args)
        {
            //整数の個数の入力 
            int Num = int.Parse(Console.ReadLine());

            //整数の入力
            string[] number = Console.ReadLine().Split(' ');


            //中央値を求めるための形にする
            double[] array = new double[number.Length];
            for (int i = 0; i < Num; i++)
            {
                array[i]= int.Parse(number[i]);
            }

            //小さい順に並べる
            Array.Sort(array);

            //偶数個の時
            if (Num%2==0)
            {
                int i = Num / 2;
                int j = (Num / 2) -1;
                //表示
                Console.WriteLine((array[i]+array[j])/2);

            }

            //奇数個の時
            else if (Num % 2 == 1)
            {
                int i = Num / 2;
                //表示
                Console.WriteLine(array[i] );
            }
                       
        }
    }
}
0