結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
49,456 KB
testcase_01 AC 40 ms
49,864 KB
testcase_02 AC 42 ms
49,280 KB
testcase_03 WA -
testcase_04 AC 41 ms
49,452 KB
testcase_05 AC 41 ms
49,376 KB
testcase_06 AC 42 ms
49,444 KB
testcase_07 AC 45 ms
49,400 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 43 ms
49,536 KB
testcase_11 RE -
testcase_12 AC 41 ms
49,508 KB
testcase_13 WA -
testcase_14 AC 40 ms
49,528 KB
testcase_15 AC 49 ms
49,532 KB
testcase_16 AC 50 ms
49,620 KB
testcase_17 AC 50 ms
49,556 KB
testcase_18 AC 44 ms
49,404 KB
testcase_19 AC 47 ms
49,272 KB
testcase_20 AC 47 ms
49,532 KB
testcase_21 AC 44 ms
49,512 KB
testcase_22 AC 47 ms
49,336 KB
testcase_23 WA -
testcase_24 AC 44 ms
49,368 KB
testcase_25 AC 48 ms
47,220 KB
testcase_26 WA -
testcase_27 AC 47 ms
49,552 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 49 ms
49,356 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 43 ms
49,372 KB
testcase_38 AC 43 ms
47,828 KB
testcase_39 AC 43 ms
49,372 KB
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

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