結果
| 問題 | No.275 中央値を求めよ |
| コンテスト | |
| ユーザー |
nanophoto12
|
| 提出日時 | 2015-12-06 19:43:34 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 1,000 ms |
| コード長 | 631 bytes |
| 記録 | |
| コンパイル時間 | 708 ms |
| コンパイル使用メモリ | 114,624 KB |
| 実行使用メモリ | 29,192 KB |
| 最終ジャッジ日時 | 2026-03-11 03:38:02 |
| 合計ジャッジ時間 | 2,694 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace No275
{
class MainClass
{
public static void Main (string[] args)
{
var n = Convert.ToInt32(Console.ReadLine ());
string[] line = Console.ReadLine ().Split(' ');
int[] data = line.Select (s => Convert.ToInt32 (s)).ToArray();
Array.Sort (data);
if (data.Length % 2 == 1) {
Console.WriteLine (data [data.Length / 2].ToString ());
return;
}
var a = data [data.Length / 2];
var b = data [data.Length / 2-1];
var mid = ((double)a + (double)b) / 2d;
Console.WriteLine (mid.ToString ());
}
}
}
nanophoto12