結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
_mi_lin_
|
| 提出日時 | 2019-04-04 11:21:23 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 1,000 ms |
| コード長 | 1,184 bytes |
| コンパイル時間 | 1,132 ms |
| コンパイル使用メモリ | 103,552 KB |
| 実行使用メモリ | 19,328 KB |
| 最終ジャッジ日時 | 2024-12-25 16:12:53 |
| 合計ジャッジ時間 | 3,520 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / 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;
using System.Threading.Tasks;
namespace No275median
{
class Program
{
static void Main(string[] args)
{
//整数の個数の入力
int Num = int.Parse(Console.ReadLine());
//整数の入力
string[] number = Console.ReadLine().Split(' ');
//中央値を求めるための形にする
double[] array = new double[number.Length];
for (int i = 0; i < Num; i++)
{
array[i]= int.Parse(number[i]);
}
//小さい順に並べる
Array.Sort(array);
//偶数個の時
if (Num%2==0)
{
int i = Num / 2;
int j = (Num / 2) -1;
//表示
Console.WriteLine((array[i]+array[j])/2);
}
//奇数個の時
else if (Num % 2 == 1)
{
int i = Num / 2;
//表示
Console.WriteLine(array[i] );
}
}
}
}
_mi_lin_