結果

問題 No.275 中央値を求めよ
ユーザー GrenacheGrenache
提出日時 2015-09-04 22:24:25
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 181 ms / 1,000 ms
コード長 574 bytes
コンパイル時間 3,025 ms
使用メモリ 41,512 KB
最終ジャッジ日時 2023-01-22 19:52:46
合計ジャッジ時間 10,677 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 103 ms
38,264 KB
testcase_01 AC 103 ms
38,196 KB
testcase_02 AC 113 ms
38,396 KB
testcase_03 AC 104 ms
38,208 KB
testcase_04 AC 104 ms
38,168 KB
testcase_05 AC 103 ms
38,132 KB
testcase_06 AC 111 ms
38,380 KB
testcase_07 AC 141 ms
39,256 KB
testcase_08 AC 115 ms
38,556 KB
testcase_09 AC 118 ms
38,344 KB
testcase_10 AC 122 ms
38,400 KB
testcase_11 AC 107 ms
38,300 KB
testcase_12 AC 101 ms
38,172 KB
testcase_13 AC 103 ms
38,240 KB
testcase_14 AC 105 ms
38,084 KB
testcase_15 AC 169 ms
39,916 KB
testcase_16 AC 163 ms
40,220 KB
testcase_17 AC 181 ms
41,356 KB
testcase_18 AC 125 ms
38,724 KB
testcase_19 AC 136 ms
39,404 KB
testcase_20 AC 144 ms
39,468 KB
testcase_21 AC 137 ms
39,212 KB
testcase_22 AC 146 ms
40,116 KB
testcase_23 AC 139 ms
39,108 KB
testcase_24 AC 124 ms
38,520 KB
testcase_25 AC 178 ms
41,512 KB
testcase_26 AC 156 ms
39,824 KB
testcase_27 AC 152 ms
39,368 KB
testcase_28 AC 108 ms
38,612 KB
testcase_29 AC 126 ms
38,692 KB
testcase_30 AC 113 ms
38,328 KB
testcase_31 AC 176 ms
41,204 KB
testcase_32 AC 117 ms
38,444 KB
testcase_33 AC 142 ms
39,788 KB
testcase_34 AC 113 ms
38,232 KB
testcase_35 AC 144 ms
39,436 KB
testcase_36 AC 137 ms
39,136 KB
testcase_37 AC 122 ms
38,524 KB
testcase_38 AC 120 ms
38,452 KB
testcase_39 AC 124 ms
38,632 KB
testcase_40 AC 174 ms
41,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main_yukicoder275 {

    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);

        double ret;
        if (n % 2 != 0) {
        	ret = a[n / 2];
        } else {
        	ret = ((double)a[n / 2] + a[n / 2 - 1]) / 2;
        }
        
        System.out.printf("%.2f\n", ret);

        sc.close();
    }
}
0