結果

問題 No.275 中央値を求めよ
ユーザー soi09476291soi09476291
提出日時 2019-11-18 11:28:16
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,239 bytes
コンパイル時間 810 ms
コンパイル使用メモリ 109,292 KB
実行使用メモリ 25,436 KB
最終ジャッジ日時 2024-04-08 16:28:37
合計ジャッジ時間 3,255 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
25,180 KB
testcase_01 AC 27 ms
25,180 KB
testcase_02 AC 27 ms
25,180 KB
testcase_03 AC 25 ms
24,412 KB
testcase_04 AC 27 ms
25,180 KB
testcase_05 AC 27 ms
25,180 KB
testcase_06 AC 27 ms
25,180 KB
testcase_07 AC 32 ms
25,436 KB
testcase_08 AC 29 ms
24,796 KB
testcase_09 WA -
testcase_10 AC 32 ms
25,436 KB
testcase_11 RE -
testcase_12 AC 26 ms
24,540 KB
testcase_13 AC 26 ms
24,412 KB
testcase_14 AC 27 ms
24,540 KB
testcase_15 AC 35 ms
25,436 KB
testcase_16 AC 33 ms
25,436 KB
testcase_17 AC 34 ms
25,436 KB
testcase_18 AC 33 ms
25,436 KB
testcase_19 AC 31 ms
24,796 KB
testcase_20 AC 34 ms
25,436 KB
testcase_21 AC 32 ms
25,436 KB
testcase_22 AC 34 ms
25,436 KB
testcase_23 AC 31 ms
24,796 KB
testcase_24 AC 33 ms
25,436 KB
testcase_25 AC 34 ms
25,436 KB
testcase_26 AC 31 ms
24,796 KB
testcase_27 AC 31 ms
24,796 KB
testcase_28 AC 26 ms
24,412 KB
testcase_29 WA -
testcase_30 AC 25 ms
24,412 KB
testcase_31 AC 34 ms
25,436 KB
testcase_32 WA -
testcase_33 AC 31 ms
24,796 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 30 ms
24,796 KB
testcase_37 AC 32 ms
25,436 KB
testcase_38 AC 32 ms
25,436 KB
testcase_39 AC 30 ms
24,796 KB
testcase_40 AC 33 ms
24,796 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Text;
using System.Linq;

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            int tem;

            int N = int.Parse(Console.ReadLine());

            var input = Console.ReadLine().Split(' ');

            int[] A = new int[N];

            for(int i = 0; i < N; i++)
            {
                A[i] = int.Parse(input[i]);
            }

            for(int i = 0; i < N - 1; i++)
            {
                for(int j = i + 1; j < N; j++)
                {
                    if(A[i] > A[j])
                    {
                        tem = A[j];
                        A[j] = A[i];
                        A[i] = tem;
                    }
                }
            }

            if(N % 2 != 0)
            {
                int j = Convert.ToInt32(Math.Round((double)N / 2));

                Console.WriteLine(A[j - 1]);
            }
            else if(N % 2 == 0)
            {
                int a = N / 2;
                int b = (N / 2) - 1;

                double d = Convert.ToDouble((A[a] + A[b]) / 2.0);

                d = d * 10;

                Console.WriteLine(Math.Floor(d) / 10);
            }
        }
    }
}
0