結果

問題 No.275 中央値を求めよ
ユーザー tentententen
提出日時 2020-11-11 09:04:35
言語 Java19
(openjdk 19.0.1)
結果
AC  
実行時間 189 ms / 1,000 ms
コード長 500 bytes
コンパイル時間 1,772 ms
実行使用メモリ 41,236 KB
最終ジャッジ日時 2023-02-22 16:49:23
合計ジャッジ時間 9,193 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
37,696 KB
testcase_01 AC 103 ms
37,804 KB
testcase_02 AC 114 ms
37,956 KB
testcase_03 AC 106 ms
37,612 KB
testcase_04 AC 100 ms
37,768 KB
testcase_05 AC 103 ms
37,632 KB
testcase_06 AC 110 ms
37,932 KB
testcase_07 AC 143 ms
39,120 KB
testcase_08 AC 115 ms
37,896 KB
testcase_09 AC 115 ms
37,928 KB
testcase_10 AC 119 ms
37,900 KB
testcase_11 AC 106 ms
37,712 KB
testcase_12 AC 99 ms
37,784 KB
testcase_13 AC 104 ms
37,720 KB
testcase_14 AC 102 ms
37,804 KB
testcase_15 AC 162 ms
39,820 KB
testcase_16 AC 189 ms
41,236 KB
testcase_17 AC 139 ms
40,816 KB
testcase_18 AC 131 ms
38,236 KB
testcase_19 AC 146 ms
39,164 KB
testcase_20 AC 147 ms
39,392 KB
testcase_21 AC 126 ms
38,436 KB
testcase_22 AC 169 ms
39,604 KB
testcase_23 AC 141 ms
38,580 KB
testcase_24 AC 123 ms
38,224 KB
testcase_25 AC 176 ms
40,592 KB
testcase_26 AC 156 ms
39,884 KB
testcase_27 AC 147 ms
39,440 KB
testcase_28 AC 110 ms
38,024 KB
testcase_29 AC 135 ms
38,352 KB
testcase_30 AC 114 ms
37,976 KB
testcase_31 AC 158 ms
40,752 KB
testcase_32 AC 117 ms
38,140 KB
testcase_33 AC 152 ms
39,440 KB
testcase_34 AC 113 ms
37,824 KB
testcase_35 AC 168 ms
40,384 KB
testcase_36 AC 136 ms
38,188 KB
testcase_37 AC 120 ms
38,032 KB
testcase_38 AC 122 ms
38,012 KB
testcase_39 AC 122 ms
38,304 KB
testcase_40 AC 189 ms
41,084 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[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        double ans;
        if (n % 2 == 0) {
            ans = (arr[n / 2 - 1] + arr[n / 2]) / 2.0;
        } else {
            ans = arr[n / 2];
        }
        System.out.println(ans);
    }
}
0