結果
問題 |
No.275 中央値を求めよ
|
ユーザー |
![]() |
提出日時 | 2017-06-01 10:24:14 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 847 bytes |
コンパイル時間 | 890 ms |
コンパイル使用メモリ | 114,240 KB |
実行使用メモリ | 30,508 KB |
最終ジャッジ日時 | 2024-09-21 21:36:29 |
合計ジャッジ時間 | 3,823 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 19 WA * 16 RE * 3 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace lecture { class Program { static void Main(string[] args) { int a = 0; double result = 0; int n = int.Parse(Console.ReadLine()); int[] data = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray(); Array.Sort(data); // 真ん中の計算 a = data.Length / 2; // 中央値の計算 if (data.Length % 2 == 0) { result = data[a] + data[a+1] / 2; Console.WriteLine(result); } else { result = data[a]; Console.WriteLine(result); } } } }