結果

問題 No.275 中央値を求めよ
ユーザー soi09476291soi09476291
提出日時 2019-11-18 11:16:32
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,238 bytes
コンパイル時間 2,887 ms
コンパイル使用メモリ 96,748 KB
実行使用メモリ 24,968 KB
最終ジャッジ日時 2023-07-24 13:16:23
合計ジャッジ時間 7,545 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
24,768 KB
testcase_01 AC 61 ms
22,612 KB
testcase_02 AC 63 ms
22,740 KB
testcase_03 WA -
testcase_04 AC 61 ms
22,780 KB
testcase_05 AC 62 ms
22,744 KB
testcase_06 AC 63 ms
24,752 KB
testcase_07 AC 71 ms
22,824 KB
testcase_08 WA -
testcase_09 AC 64 ms
20,876 KB
testcase_10 AC 69 ms
22,764 KB
testcase_11 AC 57 ms
20,836 KB
testcase_12 AC 59 ms
20,836 KB
testcase_13 WA -
testcase_14 AC 59 ms
20,844 KB
testcase_15 AC 73 ms
22,864 KB
testcase_16 AC 71 ms
22,840 KB
testcase_17 AC 70 ms
22,912 KB
testcase_18 AC 70 ms
24,836 KB
testcase_19 WA -
testcase_20 AC 71 ms
20,680 KB
testcase_21 AC 71 ms
24,832 KB
testcase_22 AC 72 ms
22,868 KB
testcase_23 WA -
testcase_24 AC 70 ms
24,740 KB
testcase_25 AC 73 ms
24,968 KB
testcase_26 WA -
testcase_27 AC 67 ms
22,972 KB
testcase_28 WA -
testcase_29 AC 65 ms
20,804 KB
testcase_30 AC 57 ms
22,960 KB
testcase_31 AC 72 ms
22,724 KB
testcase_32 AC 64 ms
20,960 KB
testcase_33 WA -
testcase_34 AC 57 ms
22,948 KB
testcase_35 AC 66 ms
20,864 KB
testcase_36 WA -
testcase_37 AC 69 ms
24,672 KB
testcase_38 AC 69 ms
22,820 KB
testcase_39 WA -
testcase_40 AC 68 ms
20,956 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]);
            }
            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.Truncate(d) / 10);
            }
        }
    }
}
0