結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-09-29 11:40:04 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 1,000 ms |
| コード長 | 479 bytes |
| コンパイル時間 | 1,414 ms |
| コンパイル使用メモリ | 103,296 KB |
| 実行使用メモリ | 19,584 KB |
| 最終ジャッジ日時 | 2024-06-25 00:40:59 |
| 合計ジャッジ時間 | 3,828 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / 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;
public class Program {
public static void Main(string[] args) {
Console.ReadLine();
string[] s = Console.ReadLine().Split(' ');
int[] array = new int[s.Length];
for (int i = 0; i < array.Length; i++) {
array[i] = int.Parse(s[i]);
}
Array.Sort(array);
if (array.Length % 2 == 0) {
float mid = (array[array.Length/2-1]+array[array.Length/2]) / 2f;
Console.WriteLine(mid);
} else {
Console.WriteLine(array[array.Length / 2]);
}
}
}