結果

問題 No.275 中央値を求めよ
ユーザー 2ch_GreenApple2ch_GreenApple
提出日時 2015-09-06 09:16:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 193 ms / 1,000 ms
コード長 499 bytes
コンパイル時間 2,173 ms
コンパイル使用メモリ 71,404 KB
実行使用メモリ 56,880 KB
最終ジャッジ日時 2023-09-07 04:38:55
合計ジャッジ時間 10,057 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,048 KB
testcase_01 AC 126 ms
55,992 KB
testcase_02 AC 140 ms
55,780 KB
testcase_03 AC 127 ms
56,072 KB
testcase_04 AC 126 ms
56,176 KB
testcase_05 AC 124 ms
55,812 KB
testcase_06 AC 137 ms
56,336 KB
testcase_07 AC 184 ms
56,128 KB
testcase_08 AC 142 ms
55,872 KB
testcase_09 AC 143 ms
55,772 KB
testcase_10 AC 143 ms
55,784 KB
testcase_11 AC 126 ms
55,804 KB
testcase_12 AC 126 ms
55,840 KB
testcase_13 AC 127 ms
55,928 KB
testcase_14 AC 126 ms
56,140 KB
testcase_15 AC 193 ms
56,832 KB
testcase_16 AC 190 ms
55,940 KB
testcase_17 AC 189 ms
56,168 KB
testcase_18 AC 156 ms
55,756 KB
testcase_19 AC 173 ms
56,344 KB
testcase_20 AC 170 ms
54,976 KB
testcase_21 AC 165 ms
56,280 KB
testcase_22 AC 186 ms
56,176 KB
testcase_23 AC 171 ms
56,132 KB
testcase_24 AC 154 ms
56,252 KB
testcase_25 AC 191 ms
56,436 KB
testcase_26 AC 189 ms
56,124 KB
testcase_27 AC 178 ms
56,216 KB
testcase_28 AC 134 ms
55,956 KB
testcase_29 AC 154 ms
56,128 KB
testcase_30 AC 134 ms
55,916 KB
testcase_31 AC 176 ms
56,168 KB
testcase_32 AC 140 ms
56,056 KB
testcase_33 AC 182 ms
56,880 KB
testcase_34 AC 133 ms
55,944 KB
testcase_35 AC 181 ms
56,228 KB
testcase_36 AC 171 ms
56,168 KB
testcase_37 AC 142 ms
55,584 KB
testcase_38 AC 153 ms
56,132 KB
testcase_39 AC 150 ms
55,756 KB
testcase_40 AC 187 ms
55,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        double[] b = new double[a];
        for (int i = 0; i < a; i++) {
            b[i] = sc.nextInt();
        }
        Arrays.sort(b);
        if (a % 2 == 1) {
            System.out.println(b[a / 2]);
        } else {
            System.out.println((b[a / 2] + b[a / 2 - 1]) / 2);
        }
    }
}
0