結果
| 問題 |
No.275 中央値を求めよ
|
| ユーザー |
|
| 提出日時 | 2022-05-27 16:25:17 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 1,000 ms |
| コード長 | 975 bytes |
| コンパイル時間 | 816 ms |
| コンパイル使用メモリ | 110,884 KB |
| 実行使用メモリ | 26,848 KB |
| 最終ジャッジ日時 | 2024-09-20 15:17:30 |
| 合計ジャッジ時間 | 2,931 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;
namespace yukicoder
{
class Program
{
static void Main(string[] args)
{
//整数の個数
string N = Console.ReadLine();
string[] str = Console.ReadLine().Split(' ');
decimal[] a = new decimal[str.Length];
decimal ans=0;
//整数
for (int i = 0; i < str.Length; i++)
{
decimal A = decimal.Parse(str[i]);
a[i] = A;
}
Array.Sort(a);
//偶数の場合
if (str.Length%2==0)
{
int i = str.Length / 2;
ans = (a[i] + a[i-1]) / 2;
}
else
{
int i = str.Length / 2;
ans = a[i];
}
Console.WriteLine(ans);
}
}
}