結果

問題 No.275 中央値を求めよ
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-09 22:49:49
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 171 ms / 1,000 ms
コード長 483 bytes
コンパイル時間 1,597 ms
使用メモリ 41,240 KB
最終ジャッジ日時 2023-01-22 21:43:24
合計ジャッジ時間 8,034 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 90 ms
37,828 KB
testcase_01 AC 88 ms
37,956 KB
testcase_02 AC 99 ms
38,020 KB
testcase_03 AC 87 ms
37,748 KB
testcase_04 AC 95 ms
37,512 KB
testcase_05 AC 91 ms
37,772 KB
testcase_06 AC 95 ms
37,836 KB
testcase_07 AC 122 ms
39,044 KB
testcase_08 AC 99 ms
37,788 KB
testcase_09 AC 107 ms
37,808 KB
testcase_10 AC 104 ms
38,232 KB
testcase_11 AC 87 ms
37,528 KB
testcase_12 AC 87 ms
37,796 KB
testcase_13 AC 89 ms
37,384 KB
testcase_14 AC 86 ms
37,752 KB
testcase_15 AC 150 ms
40,956 KB
testcase_16 AC 171 ms
41,240 KB
testcase_17 AC 155 ms
39,876 KB
testcase_18 AC 112 ms
38,104 KB
testcase_19 AC 126 ms
39,000 KB
testcase_20 AC 141 ms
41,216 KB
testcase_21 AC 122 ms
38,896 KB
testcase_22 AC 130 ms
40,928 KB
testcase_23 AC 118 ms
38,840 KB
testcase_24 AC 107 ms
38,232 KB
testcase_25 AC 155 ms
39,760 KB
testcase_26 AC 133 ms
39,188 KB
testcase_27 AC 125 ms
39,216 KB
testcase_28 AC 99 ms
37,896 KB
testcase_29 AC 115 ms
38,844 KB
testcase_30 AC 97 ms
37,540 KB
testcase_31 AC 133 ms
39,352 KB
testcase_32 AC 104 ms
37,640 KB
testcase_33 AC 129 ms
40,784 KB
testcase_34 AC 94 ms
37,676 KB
testcase_35 AC 143 ms
39,012 KB
testcase_36 AC 123 ms
38,900 KB
testcase_37 AC 110 ms
38,316 KB
testcase_38 AC 107 ms
37,956 KB
testcase_39 AC 109 ms
38,076 KB
testcase_40 AC 165 ms
40,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] A = new int [N];
        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
        }
        Arrays.sort(A);
        
        if(N%2==1){
            System.out.println(A[(N-1)/2]);
        }else{
            double r = ( A[N/2-1] + A[N/2] )/2.0 ;
            System.out.println(r);
        }
    }
}
0