結果

問題 No.275 中央値を求めよ
ユーザー qwrtpsfgqwrtpsfg
提出日時 2017-08-04 09:25:15
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 77 ms / 1,000 ms
コード長 709 bytes
コンパイル時間 4,775 ms
コンパイル使用メモリ 103,396 KB
実行使用メモリ 24,836 KB
最終ジャッジ日時 2023-09-07 06:11:54
合計ジャッジ時間 8,569 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
22,672 KB
testcase_01 AC 68 ms
22,612 KB
testcase_02 AC 69 ms
22,580 KB
testcase_03 AC 68 ms
22,604 KB
testcase_04 AC 67 ms
22,552 KB
testcase_05 AC 67 ms
24,692 KB
testcase_06 AC 67 ms
24,568 KB
testcase_07 AC 76 ms
22,644 KB
testcase_08 AC 75 ms
22,780 KB
testcase_09 AC 77 ms
22,860 KB
testcase_10 AC 75 ms
22,864 KB
testcase_11 AC 65 ms
20,700 KB
testcase_12 AC 64 ms
20,728 KB
testcase_13 AC 64 ms
20,664 KB
testcase_14 AC 64 ms
22,740 KB
testcase_15 AC 76 ms
22,888 KB
testcase_16 AC 76 ms
22,668 KB
testcase_17 AC 77 ms
22,820 KB
testcase_18 AC 74 ms
22,736 KB
testcase_19 AC 77 ms
24,832 KB
testcase_20 AC 76 ms
22,636 KB
testcase_21 AC 76 ms
22,988 KB
testcase_22 AC 77 ms
22,812 KB
testcase_23 AC 76 ms
20,812 KB
testcase_24 AC 77 ms
24,836 KB
testcase_25 AC 77 ms
20,820 KB
testcase_26 AC 75 ms
22,880 KB
testcase_27 AC 75 ms
24,828 KB
testcase_28 AC 67 ms
22,632 KB
testcase_29 AC 74 ms
22,884 KB
testcase_30 AC 67 ms
20,640 KB
testcase_31 AC 76 ms
22,872 KB
testcase_32 AC 75 ms
22,752 KB
testcase_33 AC 75 ms
22,988 KB
testcase_34 AC 68 ms
24,524 KB
testcase_35 AC 77 ms
22,876 KB
testcase_36 AC 76 ms
20,720 KB
testcase_37 AC 76 ms
22,644 KB
testcase_38 AC 75 ms
20,896 KB
testcase_39 AC 75 ms
22,776 KB
testcase_40 AC 75 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;

public class Program{
    public static void Main(){
        string s = Console.ReadLine();
        string[] input = Console.ReadLine().Split(' ');
        double[] array = new double[input.Length];
        double answer = 0;
        
        for(int i = 0; i < input.Length; i++)
        {
            array[i] = double.Parse(input[i]);
        }
        
        Array.Sort(array);
        
        //偶数の時
        if(array.Length % 2 == 0)
        {
            answer = (array[array.Length / 2] + array[(array.Length / 2) - 1]) / 2;
        }
        else
        {
            answer = array[array.Length / 2];
        }
        
        Console.WriteLine(answer);
        
    }
}
0