結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
ooh_23
|
| 提出日時 | 2017-06-01 10:23:13 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 841 bytes |
| コンパイル時間 | 859 ms |
| コンパイル使用メモリ | 106,624 KB |
| 実行使用メモリ | 20,608 KB |
| 最終ジャッジ日時 | 2024-09-21 21:36:24 |
| 合計ジャッジ時間 | 3,112 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | AC * 1 WA * 34 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 = a;
Console.WriteLine(result);
}
}
}
}
ooh_23