結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2019-04-04 10:49:08 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,212 bytes |
コンパイル時間 | 3,402 ms |
コンパイル使用メモリ | 104,064 KB |
実行使用メモリ | 18,560 KB |
最終ジャッジ日時 | 2024-12-25 14:35:41 |
合計ジャッジ時間 | 3,683 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | AC * 1 RE * 37 |
コンパイルメッセージ
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()); //整数の入力 char[] number = Console.ReadLine().ToCharArray(); //小さい順に並べる 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] ); } } } }