結果

問題 No.275 中央値を求めよ
ユーザー n_gojon_gojo
提出日時 2020-04-09 19:00:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 198 ms / 1,000 ms
コード長 809 bytes
コンパイル時間 3,580 ms
コンパイル使用メモリ 75,064 KB
実行使用メモリ 58,764 KB
最終ジャッジ日時 2023-10-11 21:25:30
合計ジャッジ時間 12,411 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,844 KB
testcase_01 AC 123 ms
56,040 KB
testcase_02 AC 141 ms
56,148 KB
testcase_03 AC 123 ms
55,664 KB
testcase_04 AC 126 ms
56,316 KB
testcase_05 AC 128 ms
55,672 KB
testcase_06 AC 139 ms
55,696 KB
testcase_07 AC 183 ms
57,484 KB
testcase_08 AC 144 ms
55,860 KB
testcase_09 AC 146 ms
56,040 KB
testcase_10 AC 145 ms
55,908 KB
testcase_11 AC 126 ms
55,848 KB
testcase_12 AC 125 ms
54,316 KB
testcase_13 AC 125 ms
55,888 KB
testcase_14 AC 126 ms
55,712 KB
testcase_15 AC 197 ms
58,764 KB
testcase_16 AC 194 ms
56,784 KB
testcase_17 AC 189 ms
56,952 KB
testcase_18 AC 181 ms
56,620 KB
testcase_19 AC 187 ms
56,936 KB
testcase_20 AC 191 ms
56,748 KB
testcase_21 AC 184 ms
56,800 KB
testcase_22 AC 193 ms
56,816 KB
testcase_23 AC 187 ms
56,144 KB
testcase_24 AC 177 ms
56,312 KB
testcase_25 AC 189 ms
56,732 KB
testcase_26 AC 180 ms
56,648 KB
testcase_27 AC 189 ms
56,520 KB
testcase_28 AC 136 ms
55,864 KB
testcase_29 AC 181 ms
56,484 KB
testcase_30 AC 139 ms
55,948 KB
testcase_31 AC 195 ms
57,124 KB
testcase_32 AC 147 ms
55,836 KB
testcase_33 AC 193 ms
56,584 KB
testcase_34 AC 140 ms
55,652 KB
testcase_35 AC 196 ms
56,800 KB
testcase_36 AC 186 ms
56,884 KB
testcase_37 AC 145 ms
56,228 KB
testcase_38 AC 178 ms
56,324 KB
testcase_39 AC 186 ms
56,708 KB
testcase_40 AC 198 ms
57,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class No275 {
    public static void main(String[] args) {
        // 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        List<Integer> intList = new ArrayList<>();
        while (sc.hasNext()) {
            intList.add(sc.nextInt());
        }
        Collections.sort(intList);

        if (n%2 == 1) {
            System.out.println(intList.get(n/2));
        } else {
            double ans = intList.get(n/2-1) + intList.get(n/2);
            System.out.println(ans/2);
        }
    }
}
0