結果
問題 | No.275 中央値を求めよ |
ユーザー |
|
提出日時 | 2022-05-27 16:11:40 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,469 bytes |
コンパイル時間 | 1,048 ms |
コンパイル使用メモリ | 106,284 KB |
実行使用メモリ | 24,192 KB |
最終ジャッジ日時 | 2024-09-20 15:16:52 |
合計ジャッジ時間 | 3,602 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 1 WA * 3 TLE * 1 -- * 33 |
コンパイルメッセージ
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(' '); int[] a = new int[str.Length]; float ans=0; //整数 for (int i = 0; i < str.Length; i++) { int A = int.Parse(str[i]); a[i] = A; } //小さい順 for(int i=0;i<str.Length;i++) { for (int j=0;j<i;j++) { if(a[j]>a[j+1]) { int temp = a[j]; a[j] = a[j + 1]; a[j + 1] = temp; i--; } } } for(int i=0;i<str.Length;i++) { //偶数の場合 if (str.Length%2==0) { i = str.Length / 2; ans = (a[i] + a[i-1]) / 2; } //奇数 else if(str.Length%2==1) { i = str.Length / 2; ans = a[i]; } if(ans>0) { break; } } Console.WriteLine(ans); } } }