結果

問題 No.275 中央値を求めよ
ユーザー tentententen
提出日時 2020-11-11 09:04:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 196 ms / 1,000 ms
コード長 500 bytes
コンパイル時間 2,150 ms
コンパイル使用メモリ 72,168 KB
実行使用メモリ 58,112 KB
最終ジャッジ日時 2023-09-30 00:23:02
合計ジャッジ時間 10,561 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,572 KB
testcase_01 AC 126 ms
56,220 KB
testcase_02 AC 139 ms
56,132 KB
testcase_03 AC 129 ms
56,008 KB
testcase_04 AC 128 ms
55,684 KB
testcase_05 AC 128 ms
55,600 KB
testcase_06 AC 136 ms
55,992 KB
testcase_07 AC 185 ms
56,472 KB
testcase_08 AC 144 ms
55,556 KB
testcase_09 AC 145 ms
55,592 KB
testcase_10 AC 146 ms
55,892 KB
testcase_11 AC 124 ms
55,932 KB
testcase_12 AC 124 ms
55,908 KB
testcase_13 AC 125 ms
55,436 KB
testcase_14 AC 128 ms
55,440 KB
testcase_15 AC 188 ms
56,296 KB
testcase_16 AC 196 ms
56,256 KB
testcase_17 AC 191 ms
56,656 KB
testcase_18 AC 158 ms
55,752 KB
testcase_19 AC 188 ms
56,100 KB
testcase_20 AC 187 ms
56,112 KB
testcase_21 AC 168 ms
56,140 KB
testcase_22 AC 178 ms
55,968 KB
testcase_23 AC 172 ms
56,268 KB
testcase_24 AC 153 ms
55,884 KB
testcase_25 AC 194 ms
58,112 KB
testcase_26 AC 190 ms
56,240 KB
testcase_27 AC 185 ms
56,160 KB
testcase_28 AC 139 ms
55,984 KB
testcase_29 AC 158 ms
56,128 KB
testcase_30 AC 139 ms
55,896 KB
testcase_31 AC 192 ms
56,060 KB
testcase_32 AC 145 ms
55,972 KB
testcase_33 AC 179 ms
56,144 KB
testcase_34 AC 141 ms
55,444 KB
testcase_35 AC 188 ms
55,772 KB
testcase_36 AC 170 ms
55,988 KB
testcase_37 AC 144 ms
55,844 KB
testcase_38 AC 154 ms
55,904 KB
testcase_39 AC 155 ms
54,040 KB
testcase_40 AC 189 ms
55,104 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