結果

問題 No.275 中央値を求めよ
ユーザー face4face4
提出日時 2018-04-10 00:10:39
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 97 ms / 1,000 ms
コード長 704 bytes
コンパイル時間 1,768 ms
使用メモリ 43,880 KB
最終ジャッジ日時 2023-01-22 23:34:26
合計ジャッジ時間 7,364 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 93 ms
42,440 KB
testcase_01 AC 92 ms
42,940 KB
testcase_02 AC 92 ms
43,880 KB
testcase_03 AC 91 ms
42,784 KB
testcase_04 AC 91 ms
42,652 KB
testcase_05 AC 92 ms
42,976 KB
testcase_06 AC 92 ms
42,844 KB
testcase_07 AC 96 ms
42,476 KB
testcase_08 AC 93 ms
42,140 KB
testcase_09 AC 92 ms
42,940 KB
testcase_10 AC 93 ms
43,108 KB
testcase_11 AC 94 ms
42,372 KB
testcase_12 AC 92 ms
43,024 KB
testcase_13 AC 89 ms
42,364 KB
testcase_14 AC 92 ms
42,528 KB
testcase_15 AC 96 ms
42,940 KB
testcase_16 AC 97 ms
43,084 KB
testcase_17 AC 95 ms
42,364 KB
testcase_18 AC 96 ms
42,384 KB
testcase_19 AC 94 ms
42,884 KB
testcase_20 AC 96 ms
42,556 KB
testcase_21 AC 95 ms
43,152 KB
testcase_22 AC 95 ms
42,392 KB
testcase_23 AC 92 ms
42,940 KB
testcase_24 AC 95 ms
42,456 KB
testcase_25 AC 94 ms
42,600 KB
testcase_26 AC 95 ms
42,856 KB
testcase_27 AC 94 ms
42,476 KB
testcase_28 AC 90 ms
42,176 KB
testcase_29 AC 93 ms
42,800 KB
testcase_30 AC 90 ms
42,592 KB
testcase_31 AC 93 ms
43,016 KB
testcase_32 AC 90 ms
42,140 KB
testcase_33 AC 93 ms
42,312 KB
testcase_34 AC 91 ms
42,200 KB
testcase_35 AC 94 ms
42,300 KB
testcase_36 AC 93 ms
42,184 KB
testcase_37 AC 94 ms
42,808 KB
testcase_38 AC 92 ms
42,892 KB
testcase_39 AC 91 ms
42,352 KB
testcase_40 AC 97 ms
42,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] arr = new int[n];
        String[] input = br.readLine().split(" ");
        for(int i = 0; i < n; i++){
            arr[i] = Integer.parseInt(input[i]);
        }

        Arrays.sort(arr);

        if(n%2 == 0){
            System.out.printf("%.1f%n", (arr[n/2] + arr[n/2-1])/2.0);
        }else{
            System.out.printf("%d%n", arr[n/2]);
        }
    }
}
0