結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-31 01:40:42 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 1,000 ms |
| コード長 | 1,227 bytes |
| コンパイル時間 | 2,915 ms |
| コンパイル使用メモリ | 109,012 KB |
| 実行使用メモリ | 18,816 KB |
| 最終ジャッジ日時 | 2024-11-22 09:46:30 |
| 合計ジャッジ時間 | 3,591 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
#if LocalDebug
var exStdIn = new System.IO.StreamReader("stdin.txt");
System.Console.SetIn(exStdIn);
#endif
var Num = GetData();
var RowData = GetList();
List<int> SortedData = new List<int>();
foreach (var n in RowData)
{
SortedData.Add(int.Parse(n));
}
SortedData.Sort();
if (SortedData.Count % 2 == 0)
{
decimal Output = (decimal)(SortedData[(SortedData.Count / 2) - 1] + SortedData[SortedData.Count / 2]) / 2;
Console.WriteLine(Output);
}
else
{
var Output = SortedData[SortedData.Count / 2];
Console.WriteLine(Output);
}
#if LocalDebug
System.Console.ReadKey();
#endif
}
static int GetData()
{
return int.Parse(Console.ReadLine());
}
static string[] GetList()
{
return Console.ReadLine().Split(' ');
}
}
}