結果

問題 No.275 中央値を求めよ
ユーザー zmirezzmirez
提出日時 2018-04-30 02:15:16
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 76 ms / 1,000 ms
コード長 883 bytes
コンパイル時間 2,061 ms
コンパイル使用メモリ 102,188 KB
実行使用メモリ 24,928 KB
最終ジャッジ日時 2023-09-07 06:58:00
合計ジャッジ時間 6,633 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
22,636 KB
testcase_01 AC 65 ms
22,576 KB
testcase_02 AC 65 ms
20,584 KB
testcase_03 AC 59 ms
20,764 KB
testcase_04 AC 64 ms
22,632 KB
testcase_05 AC 64 ms
24,728 KB
testcase_06 AC 65 ms
22,628 KB
testcase_07 AC 72 ms
20,716 KB
testcase_08 AC 66 ms
20,988 KB
testcase_09 AC 66 ms
21,032 KB
testcase_10 AC 72 ms
24,928 KB
testcase_11 AC 59 ms
20,716 KB
testcase_12 AC 62 ms
20,720 KB
testcase_13 AC 59 ms
20,656 KB
testcase_14 AC 61 ms
20,800 KB
testcase_15 AC 76 ms
22,964 KB
testcase_16 AC 73 ms
22,900 KB
testcase_17 AC 73 ms
22,804 KB
testcase_18 AC 72 ms
24,884 KB
testcase_19 AC 68 ms
18,844 KB
testcase_20 AC 74 ms
22,856 KB
testcase_21 AC 72 ms
22,924 KB
testcase_22 AC 75 ms
22,896 KB
testcase_23 AC 67 ms
21,076 KB
testcase_24 AC 73 ms
20,844 KB
testcase_25 AC 75 ms
24,820 KB
testcase_26 AC 69 ms
22,992 KB
testcase_27 AC 68 ms
20,888 KB
testcase_28 AC 59 ms
20,792 KB
testcase_29 AC 67 ms
20,840 KB
testcase_30 AC 60 ms
22,764 KB
testcase_31 AC 73 ms
22,948 KB
testcase_32 AC 65 ms
21,004 KB
testcase_33 AC 68 ms
20,940 KB
testcase_34 AC 59 ms
20,720 KB
testcase_35 AC 68 ms
21,012 KB
testcase_36 AC 68 ms
20,888 KB
testcase_37 AC 72 ms
24,776 KB
testcase_38 AC 72 ms
20,716 KB
testcase_39 AC 68 ms
23,000 KB
testcase_40 AC 70 ms
20,960 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
class Program{
    static void Main(string[]args){
        string N=Console.ReadLine();
        string A=Console.ReadLine();
        string[]t=A.Split(' ');
        long[]a=new long[t.Length];
        for(int i=0;i<a.Length;i++){
            a[i]=long.Parse(t[i]);
        }
        int n=int.Parse(N);
        
        //ソート
        for(int i=0;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                if(a[i]>a[j]){
                    long k=a[i];
                    a[i]=a[j];
                    a[j]=k;
                }
            }
        }
        // for(int i=0;i<n;i++){
        //     Console.Write(a[i]);
        // }
        if(n%2==1){
            Console.WriteLine(a[n/2]);
        }else if(n%2==0){
            long sum=a[n/2]+a[n/2-1];
            Console.WriteLine(sum/2.0);
        }
        
    }
}
0