結果

問題 No.275 中央値を求めよ
ユーザー n.yn.y
提出日時 2022-05-27 15:48:12
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,477 bytes
コンパイル時間 2,110 ms
コンパイル使用メモリ 108,600 KB
実行使用メモリ 29,344 KB
最終ジャッジ日時 2023-10-20 19:43:00
合計ジャッジ時間 3,745 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

using System;

namespace yukicoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //整数の個数
            string N = Console.ReadLine();

            string[] str = Console.ReadLine().Split(' ');
            float[] a = new float[str.Length];

            float ans=0;
            //整数
            for (int i = 0; i < str.Length; i++)
            {
                float 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])
                    {
                        float 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);
        }
    }
}
0