結果

問題 No.275 中央値を求めよ
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-09 22:49:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 198 ms / 1,000 ms
コード長 483 bytes
コンパイル時間 2,162 ms
コンパイル使用メモリ 73,040 KB
実行使用メモリ 57,348 KB
最終ジャッジ日時 2023-09-07 05:41:49
合計ジャッジ時間 10,361 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
53,872 KB
testcase_01 AC 128 ms
55,512 KB
testcase_02 AC 144 ms
55,964 KB
testcase_03 AC 129 ms
56,072 KB
testcase_04 AC 131 ms
56,108 KB
testcase_05 AC 125 ms
55,728 KB
testcase_06 AC 138 ms
55,920 KB
testcase_07 AC 184 ms
56,852 KB
testcase_08 AC 143 ms
55,740 KB
testcase_09 AC 145 ms
55,920 KB
testcase_10 AC 145 ms
55,616 KB
testcase_11 AC 125 ms
56,096 KB
testcase_12 AC 126 ms
56,020 KB
testcase_13 AC 126 ms
55,888 KB
testcase_14 AC 125 ms
54,052 KB
testcase_15 AC 187 ms
56,020 KB
testcase_16 AC 191 ms
55,084 KB
testcase_17 AC 196 ms
55,672 KB
testcase_18 AC 162 ms
56,168 KB
testcase_19 AC 180 ms
56,932 KB
testcase_20 AC 193 ms
55,772 KB
testcase_21 AC 169 ms
56,088 KB
testcase_22 AC 194 ms
55,984 KB
testcase_23 AC 165 ms
56,300 KB
testcase_24 AC 155 ms
53,924 KB
testcase_25 AC 195 ms
57,348 KB
testcase_26 AC 186 ms
55,860 KB
testcase_27 AC 187 ms
56,320 KB
testcase_28 AC 136 ms
55,812 KB
testcase_29 AC 165 ms
56,000 KB
testcase_30 AC 141 ms
56,092 KB
testcase_31 AC 198 ms
56,476 KB
testcase_32 AC 147 ms
55,948 KB
testcase_33 AC 187 ms
56,340 KB
testcase_34 AC 140 ms
55,880 KB
testcase_35 AC 193 ms
55,844 KB
testcase_36 AC 165 ms
56,172 KB
testcase_37 AC 146 ms
55,936 KB
testcase_38 AC 159 ms
56,212 KB
testcase_39 AC 154 ms
55,792 KB
testcase_40 AC 193 ms
56,412 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