結果

問題 No.275 中央値を求めよ
ユーザー jonki324jonki324
提出日時 2018-06-03 16:58:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 194 ms / 1,000 ms
コード長 532 bytes
コンパイル時間 2,254 ms
コンパイル使用メモリ 72,036 KB
実行使用メモリ 56,476 KB
最終ジャッジ日時 2023-09-07 07:21:42
合計ジャッジ時間 10,021 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,572 KB
testcase_01 AC 124 ms
55,688 KB
testcase_02 AC 135 ms
55,624 KB
testcase_03 AC 125 ms
55,720 KB
testcase_04 AC 121 ms
55,656 KB
testcase_05 AC 120 ms
55,672 KB
testcase_06 AC 131 ms
55,492 KB
testcase_07 AC 176 ms
56,412 KB
testcase_08 AC 145 ms
55,776 KB
testcase_09 AC 140 ms
55,880 KB
testcase_10 AC 139 ms
55,640 KB
testcase_11 AC 123 ms
55,816 KB
testcase_12 AC 124 ms
55,632 KB
testcase_13 AC 126 ms
55,752 KB
testcase_14 AC 123 ms
55,584 KB
testcase_15 AC 188 ms
55,980 KB
testcase_16 AC 187 ms
55,972 KB
testcase_17 AC 188 ms
56,084 KB
testcase_18 AC 160 ms
55,696 KB
testcase_19 AC 194 ms
55,904 KB
testcase_20 AC 176 ms
54,588 KB
testcase_21 AC 168 ms
56,060 KB
testcase_22 AC 183 ms
55,976 KB
testcase_23 AC 180 ms
56,444 KB
testcase_24 AC 159 ms
55,836 KB
testcase_25 AC 186 ms
56,476 KB
testcase_26 AC 179 ms
55,724 KB
testcase_27 AC 176 ms
54,196 KB
testcase_28 AC 132 ms
55,752 KB
testcase_29 AC 176 ms
56,100 KB
testcase_30 AC 140 ms
55,772 KB
testcase_31 AC 183 ms
56,044 KB
testcase_32 AC 144 ms
55,796 KB
testcase_33 AC 194 ms
55,932 KB
testcase_34 AC 136 ms
55,696 KB
testcase_35 AC 179 ms
56,088 KB
testcase_36 AC 169 ms
55,844 KB
testcase_37 AC 141 ms
55,604 KB
testcase_38 AC 149 ms
55,920 KB
testcase_39 AC 160 ms
55,784 KB
testcase_40 AC 185 ms
56,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a);
        int j = n / 2;
        if (n % 2 != 0) {
            System.out.println(a[j]);
        } else {
            System.out.println((double)(a[j - 1] + a[j]) / 2);
        }
        scan.close();
    }
}
0