結果
問題 |
No.275 中央値を求めよ
|
ユーザー |
![]() |
提出日時 | 2019-04-04 10:52:51 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,199 bytes |
コンパイル時間 | 2,617 ms |
コンパイル使用メモリ | 103,936 KB |
実行使用メモリ | 19,840 KB |
最終ジャッジ日時 | 2024-12-25 14:46:30 |
合計ジャッジ時間 | 5,814 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 32 |
コンパイルメッセージ
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(' '); //小さい順に並べる Array.Sort(number); //中央値を求めるための形にする double[] array = new double[Num]; for (int i = 0; i < number.Length; i++) { array[i]= double.Parse(number[i].ToString()); } //偶数個の時 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] ); } } } }