結果
| 問題 |
No.275 中央値を求めよ
|
| ユーザー |
|
| 提出日時 | 2023-08-25 14:10:33 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 41 ms / 1,000 ms |
| コード長 | 744 bytes |
| コンパイル時間 | 1,124 ms |
| コンパイル使用メモリ | 112,284 KB |
| 実行使用メモリ | 20,608 KB |
| 最終ジャッジ日時 | 2024-12-23 22:31:56 |
| 合計ジャッジ時間 | 4,059 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / 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;
using System.Linq;
namespace PracticeAtCoder
{
class Program
{
static void Main(string[] args)
{
//中央値
string sA = Console.ReadLine();
int intN = int.Parse(sA);
Boolean flg = true;
if(intN % 2 == 0){
flg = true;
intN = intN/2;
}else{
flg = false;
intN = intN/2;
}
string sB = Console.ReadLine();
string[] t = sB.Split(' ');
int[] after = t.Select(s => int.Parse(s)).ToArray();
double bolA = 0;
//ソートが必要
Array.Sort(after);
if(flg){
bolA = (after[intN-1] +after[intN]);
Console.WriteLine(bolA/2);
}else{
Console.WriteLine(after[intN]);
}
}
}
}