結果

問題 No.275 中央値を求めよ
ユーザー Hiroaki KonoHiroaki Kono
提出日時 2017-10-26 21:36:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 654 bytes
コンパイル時間 3,990 ms
コンパイル使用メモリ 76,452 KB
実行使用メモリ 42,972 KB
最終ジャッジ日時 2024-05-01 15:17:40
合計ジャッジ時間 11,692 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 131 ms
41,408 KB
testcase_04 AC 130 ms
41,540 KB
testcase_05 WA -
testcase_06 AC 142 ms
41,720 KB
testcase_07 AC 185 ms
42,044 KB
testcase_08 AC 145 ms
41,528 KB
testcase_09 AC 155 ms
41,980 KB
testcase_10 WA -
testcase_11 AC 135 ms
41,336 KB
testcase_12 AC 139 ms
41,568 KB
testcase_13 AC 134 ms
41,300 KB
testcase_14 AC 134 ms
41,436 KB
testcase_15 WA -
testcase_16 AC 201 ms
42,900 KB
testcase_17 AC 199 ms
42,452 KB
testcase_18 WA -
testcase_19 AC 188 ms
42,364 KB
testcase_20 AC 186 ms
42,612 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 176 ms
42,112 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 190 ms
42,672 KB
testcase_27 AC 192 ms
42,468 KB
testcase_28 AC 141 ms
41,700 KB
testcase_29 AC 168 ms
41,876 KB
testcase_30 AC 137 ms
41,384 KB
testcase_31 AC 185 ms
42,580 KB
testcase_32 AC 143 ms
41,564 KB
testcase_33 AC 184 ms
42,492 KB
testcase_34 AC 137 ms
41,972 KB
testcase_35 AC 185 ms
42,144 KB
testcase_36 AC 167 ms
42,228 KB
testcase_37 AC 138 ms
41,668 KB
testcase_38 AC 149 ms
41,960 KB
testcase_39 AC 169 ms
41,828 KB
testcase_40 AC 195 ms
42,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Scanner;

public class No275 {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int count = s.nextInt();
        int[] arr = new int[count];
        for (int i = 0; i < count; i++) {
            arr[i] = s.nextInt();
        }
        Arrays.sort(arr);

        double median;
        if (count % 2 == 0) {
            median = (double) ((arr[count / 2] + arr[count / 2 - 1]) / 2);
        } else {
            median = (double) arr[count / 2];
        }
        System.out.println(new DecimalFormat(".#").format(median));
    }
}
0