結果

問題 No.275 中央値を求めよ
ユーザー トミートミー
提出日時 2024-04-01 15:13:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 209 ms / 1,000 ms
コード長 519 bytes
コンパイル時間 6,023 ms
コンパイル使用メモリ 74,092 KB
実行使用メモリ 58,348 KB
最終ジャッジ日時 2024-04-01 15:13:21
合計ジャッジ時間 10,798 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
57,952 KB
testcase_01 AC 115 ms
56,808 KB
testcase_02 AC 135 ms
58,212 KB
testcase_03 AC 125 ms
57,852 KB
testcase_04 AC 127 ms
57,972 KB
testcase_05 AC 138 ms
58,080 KB
testcase_06 AC 146 ms
58,168 KB
testcase_07 AC 165 ms
58,084 KB
testcase_08 AC 153 ms
57,968 KB
testcase_09 AC 142 ms
57,844 KB
testcase_10 AC 144 ms
58,088 KB
testcase_11 AC 128 ms
57,800 KB
testcase_12 AC 127 ms
57,904 KB
testcase_13 AC 134 ms
57,820 KB
testcase_14 AC 138 ms
57,828 KB
testcase_15 AC 182 ms
58,216 KB
testcase_16 AC 187 ms
58,220 KB
testcase_17 AC 198 ms
58,328 KB
testcase_18 AC 153 ms
57,956 KB
testcase_19 AC 194 ms
58,064 KB
testcase_20 AC 183 ms
58,212 KB
testcase_21 AC 171 ms
58,096 KB
testcase_22 AC 188 ms
58,220 KB
testcase_23 AC 174 ms
58,308 KB
testcase_24 AC 149 ms
58,092 KB
testcase_25 AC 209 ms
58,088 KB
testcase_26 AC 183 ms
57,968 KB
testcase_27 AC 178 ms
58,080 KB
testcase_28 AC 136 ms
57,956 KB
testcase_29 AC 178 ms
58,060 KB
testcase_30 AC 138 ms
57,952 KB
testcase_31 AC 189 ms
58,336 KB
testcase_32 AC 160 ms
57,968 KB
testcase_33 AC 191 ms
58,348 KB
testcase_34 AC 139 ms
57,964 KB
testcase_35 AC 188 ms
58,040 KB
testcase_36 AC 173 ms
58,084 KB
testcase_37 AC 140 ms
58,084 KB
testcase_38 AC 148 ms
58,076 KB
testcase_39 AC 151 ms
58,084 KB
testcase_40 AC 182 ms
58,092 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 == 0) {
            System.out.println((double)(a[n / 2 - 1] + a[n / 2]) / 2);
            
        } else {
            System.out.println(a[n / 2]);
            
        }

        sc.close();

    }
}
0