結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
nanophoto12
|
| 提出日時 | 2015-12-06 19:43:34 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 37 ms / 1,000 ms |
| コード長 | 631 bytes |
| コンパイル時間 | 1,077 ms |
| コンパイル使用メモリ | 107,136 KB |
| 実行使用メモリ | 20,736 KB |
| 最終ジャッジ日時 | 2024-06-24 23:32:28 |
| 合計ジャッジ時間 | 3,355 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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