結果

問題 No.275 中央値を求めよ
ユーザー bayashiko_rbayashiko_r
提出日時 2018-10-31 00:50:00
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 74 ms / 1,000 ms
コード長 753 bytes
コンパイル時間 3,786 ms
コンパイル使用メモリ 102,732 KB
実行使用メモリ 24,804 KB
最終ジャッジ日時 2023-09-07 07:39:13
合計ジャッジ時間 8,139 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
22,604 KB
testcase_01 AC 64 ms
22,556 KB
testcase_02 AC 66 ms
22,644 KB
testcase_03 AC 64 ms
22,560 KB
testcase_04 AC 64 ms
20,536 KB
testcase_05 AC 65 ms
24,620 KB
testcase_06 AC 65 ms
24,548 KB
testcase_07 AC 73 ms
22,824 KB
testcase_08 AC 71 ms
22,512 KB
testcase_09 AC 71 ms
22,720 KB
testcase_10 AC 71 ms
22,816 KB
testcase_11 AC 61 ms
22,536 KB
testcase_12 AC 62 ms
20,720 KB
testcase_13 AC 62 ms
20,596 KB
testcase_14 AC 61 ms
22,720 KB
testcase_15 AC 72 ms
24,804 KB
testcase_16 AC 72 ms
22,696 KB
testcase_17 AC 71 ms
22,676 KB
testcase_18 AC 72 ms
22,568 KB
testcase_19 AC 72 ms
22,616 KB
testcase_20 AC 71 ms
22,648 KB
testcase_21 AC 72 ms
24,704 KB
testcase_22 AC 71 ms
22,588 KB
testcase_23 AC 72 ms
24,752 KB
testcase_24 AC 72 ms
24,668 KB
testcase_25 AC 72 ms
24,624 KB
testcase_26 AC 72 ms
22,644 KB
testcase_27 AC 72 ms
22,700 KB
testcase_28 AC 64 ms
22,536 KB
testcase_29 AC 72 ms
22,632 KB
testcase_30 AC 64 ms
22,516 KB
testcase_31 AC 71 ms
20,564 KB
testcase_32 AC 70 ms
24,700 KB
testcase_33 AC 72 ms
22,684 KB
testcase_34 AC 64 ms
22,528 KB
testcase_35 AC 71 ms
22,588 KB
testcase_36 AC 72 ms
22,560 KB
testcase_37 AC 71 ms
24,696 KB
testcase_38 AC 72 ms
22,608 KB
testcase_39 AC 74 ms
22,552 KB
testcase_40 AC 74 ms
22,608 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.Linq;

class Program {
    static void Main(string[] args) {
        //個数の入力
        int N = int.Parse(Console.ReadLine());
        //数字の入力
        string input = Console.ReadLine();
        string[] num_string = input.Split(' ');
        double[] num = new double[N];
        //数字の割り当て
        for (int i = 0; i < N; i++) {
            num[i] = int.Parse(num_string[i]);
        }

        //数字の並び替え
        Array.Sort(num);
        //Nが奇数の時
        if (N % 2 == 1) {
            Console.WriteLine(num[(N - 1) / 2]);
        }

        //Nが偶数の時
        if (N % 2 == 0) {
            Console.WriteLine((num[(N / 2) - 1] + num[N / 2]) / 2);
        }
    }
}
0