結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2015-11-18 09:30:34 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 35 ms / 1,000 ms |
コード長 | 533 bytes |
コンパイル時間 | 814 ms |
コンパイル使用メモリ | 114,708 KB |
実行使用メモリ | 27,492 KB |
最終ジャッジ日時 | 2024-06-24 23:31:25 |
合計ジャッジ時間 | 3,296 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; class Program { static void Main() { int n = int.Parse(Console.ReadLine()); double[] a = new double[n]; string[] s = Console.ReadLine().Split(); for (int i=0;i< n; i++) { a[i] = double.Parse(s[i]); } Array.Sort(a); double med = 0; if (n % 2 == 1) { med = a[(n - 1) / 2]; } else { med = (a[n / 2] + a[n / 2 - 1]) / 2; } Console.WriteLine(med); } }