結果

問題 No.275 中央値を求めよ
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-05-02 21:46:03
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 829 bytes
コンパイル時間 2,071 ms
コンパイル使用メモリ 72,648 KB
実行使用メモリ 49,912 KB
最終ジャッジ日時 2023-10-12 05:17:56
合計ジャッジ時間 5,731 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
49,444 KB
testcase_01 AC 47 ms
49,356 KB
testcase_02 AC 47 ms
49,556 KB
testcase_03 WA -
testcase_04 AC 46 ms
49,312 KB
testcase_05 AC 45 ms
49,384 KB
testcase_06 AC 47 ms
49,340 KB
testcase_07 AC 50 ms
49,308 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 48 ms
49,480 KB
testcase_11 RE -
testcase_12 AC 45 ms
49,256 KB
testcase_13 WA -
testcase_14 AC 46 ms
49,244 KB
testcase_15 AC 54 ms
49,516 KB
testcase_16 AC 55 ms
49,408 KB
testcase_17 AC 54 ms
49,572 KB
testcase_18 AC 48 ms
49,556 KB
testcase_19 WA -
testcase_20 AC 51 ms
49,412 KB
testcase_21 AC 48 ms
49,348 KB
testcase_22 AC 56 ms
49,760 KB
testcase_23 WA -
testcase_24 AC 49 ms
49,204 KB
testcase_25 AC 53 ms
49,624 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 48 ms
47,780 KB
testcase_30 AC 47 ms
49,372 KB
testcase_31 AC 54 ms
49,364 KB
testcase_32 AC 47 ms
49,404 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 48 ms
49,388 KB
testcase_38 AC 48 ms
49,400 KB
testcase_39 WA -
testcase_40 AC 54 ms
49,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

import static java.lang.System.in;


public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int N = Integer.parseInt(reader.readLine());
        int[] table = new int[N];
        String[] inputs = reader.readLine().split(" ");
        for (int i = 0; i < N; i++) {
            table[i] = Integer.parseInt(inputs[i]);
        }
        Arrays.sort(table);
        if (N % 2 == 0) {
            int left = table[(N/2)-1];
            int right = table[(N/2)];
            System.out.println((left + right) / 2.0);
        } else {
            System.out.println(table[(N/2)+1]);
        }
    }
}
0