結果

問題 No.275 中央値を求めよ
ユーザー ub_nyaoiixub_nyaoiix
提出日時 2016-12-17 16:05:55
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 74 ms / 1,000 ms
コード長 404 bytes
コンパイル時間 3,452 ms
コンパイル使用メモリ 104,816 KB
実行使用メモリ 24,900 KB
最終ジャッジ日時 2023-09-07 05:43:04
合計ジャッジ時間 6,436 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
24,808 KB
testcase_01 AC 65 ms
22,644 KB
testcase_02 AC 65 ms
22,588 KB
testcase_03 AC 64 ms
24,732 KB
testcase_04 AC 65 ms
24,712 KB
testcase_05 AC 64 ms
22,564 KB
testcase_06 AC 65 ms
24,664 KB
testcase_07 AC 73 ms
22,716 KB
testcase_08 AC 72 ms
24,832 KB
testcase_09 AC 71 ms
22,796 KB
testcase_10 AC 71 ms
22,684 KB
testcase_11 AC 63 ms
22,628 KB
testcase_12 AC 62 ms
20,656 KB
testcase_13 AC 62 ms
22,676 KB
testcase_14 AC 62 ms
20,792 KB
testcase_15 AC 73 ms
22,852 KB
testcase_16 AC 73 ms
24,800 KB
testcase_17 AC 73 ms
24,836 KB
testcase_18 AC 72 ms
22,700 KB
testcase_19 AC 72 ms
24,900 KB
testcase_20 AC 73 ms
22,708 KB
testcase_21 AC 73 ms
22,832 KB
testcase_22 AC 73 ms
24,748 KB
testcase_23 AC 72 ms
22,664 KB
testcase_24 AC 74 ms
22,780 KB
testcase_25 AC 73 ms
22,640 KB
testcase_26 AC 72 ms
22,756 KB
testcase_27 AC 73 ms
22,756 KB
testcase_28 AC 65 ms
22,652 KB
testcase_29 AC 72 ms
24,768 KB
testcase_30 AC 65 ms
22,724 KB
testcase_31 AC 74 ms
24,760 KB
testcase_32 AC 71 ms
22,816 KB
testcase_33 AC 72 ms
22,732 KB
testcase_34 AC 64 ms
22,592 KB
testcase_35 AC 73 ms
24,812 KB
testcase_36 AC 72 ms
22,744 KB
testcase_37 AC 72 ms
22,644 KB
testcase_38 AC 72 ms
22,700 KB
testcase_39 AC 72 ms
22,696 KB
testcase_40 AC 73 ms
24,844 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class Q0275
{
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());

		string[] num = Console.ReadLine().Split(' ');
		int[] a = new int[n];
		for (int i=0; i<n; i++)
		{
			a[i] = int.Parse(num[i]);
		}

		Array.Sort(a);

		float output;
		if(n%2 > 0)
		{
			output = a[n/2];
		}
		else
		{
			output = (float)(a[n/2] + a[n/2-1])/2;
		}

		Console.WriteLine(output);
	}
}
0