結果

問題 No.275 中央値を求めよ
ユーザー face4face4
提出日時 2018-04-10 00:10:39
言語 Java19
(openjdk 21)
結果
AC  
実行時間 121 ms / 1,000 ms
コード長 704 bytes
コンパイル時間 2,133 ms
コンパイル使用メモリ 72,132 KB
実行使用メモリ 56,216 KB
最終ジャッジ日時 2023-09-07 06:52:48
合計ジャッジ時間 8,720 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
55,724 KB
testcase_01 AC 114 ms
55,444 KB
testcase_02 AC 115 ms
55,716 KB
testcase_03 AC 113 ms
55,740 KB
testcase_04 AC 112 ms
56,036 KB
testcase_05 AC 116 ms
55,756 KB
testcase_06 AC 113 ms
55,716 KB
testcase_07 AC 116 ms
55,572 KB
testcase_08 AC 113 ms
55,616 KB
testcase_09 AC 109 ms
55,888 KB
testcase_10 AC 111 ms
55,984 KB
testcase_11 AC 111 ms
56,112 KB
testcase_12 AC 116 ms
55,620 KB
testcase_13 AC 116 ms
54,036 KB
testcase_14 AC 115 ms
55,940 KB
testcase_15 AC 119 ms
55,500 KB
testcase_16 AC 120 ms
55,728 KB
testcase_17 AC 119 ms
55,852 KB
testcase_18 AC 117 ms
55,464 KB
testcase_19 AC 119 ms
55,652 KB
testcase_20 AC 121 ms
53,668 KB
testcase_21 AC 118 ms
53,428 KB
testcase_22 AC 116 ms
55,452 KB
testcase_23 AC 115 ms
55,444 KB
testcase_24 AC 117 ms
55,592 KB
testcase_25 AC 118 ms
55,476 KB
testcase_26 AC 119 ms
55,244 KB
testcase_27 AC 119 ms
55,636 KB
testcase_28 AC 116 ms
56,028 KB
testcase_29 AC 115 ms
55,788 KB
testcase_30 AC 115 ms
55,772 KB
testcase_31 AC 119 ms
55,656 KB
testcase_32 AC 115 ms
55,776 KB
testcase_33 AC 119 ms
55,620 KB
testcase_34 AC 116 ms
56,216 KB
testcase_35 AC 116 ms
55,672 KB
testcase_36 AC 115 ms
55,668 KB
testcase_37 AC 115 ms
55,460 KB
testcase_38 AC 116 ms
55,940 KB
testcase_39 AC 116 ms
55,768 KB
testcase_40 AC 121 ms
55,772 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