結果

問題 No.275 中央値を求めよ
ユーザー YOSHIYOSHI
提出日時 2021-03-08 18:56:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 86 ms / 1,000 ms
コード長 614 bytes
コンパイル時間 3,514 ms
コンパイル使用メモリ 78,888 KB
実行使用メモリ 54,652 KB
最終ジャッジ日時 2023-07-31 17:38:24
合計ジャッジ時間 8,591 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
51,472 KB
testcase_01 AC 59 ms
51,548 KB
testcase_02 AC 61 ms
51,924 KB
testcase_03 AC 59 ms
51,480 KB
testcase_04 AC 59 ms
51,268 KB
testcase_05 AC 58 ms
51,540 KB
testcase_06 AC 59 ms
51,444 KB
testcase_07 AC 82 ms
53,720 KB
testcase_08 AC 62 ms
51,408 KB
testcase_09 AC 60 ms
49,896 KB
testcase_10 AC 60 ms
51,404 KB
testcase_11 AC 59 ms
51,368 KB
testcase_12 AC 60 ms
51,388 KB
testcase_13 AC 60 ms
51,444 KB
testcase_14 AC 59 ms
51,216 KB
testcase_15 AC 85 ms
54,184 KB
testcase_16 AC 85 ms
54,652 KB
testcase_17 AC 86 ms
53,704 KB
testcase_18 AC 64 ms
52,780 KB
testcase_19 AC 82 ms
52,940 KB
testcase_20 AC 84 ms
53,664 KB
testcase_21 AC 78 ms
52,452 KB
testcase_22 AC 69 ms
53,184 KB
testcase_23 AC 82 ms
53,992 KB
testcase_24 AC 66 ms
52,524 KB
testcase_25 AC 85 ms
54,452 KB
testcase_26 AC 78 ms
54,508 KB
testcase_27 AC 77 ms
54,268 KB
testcase_28 AC 61 ms
51,372 KB
testcase_29 AC 80 ms
52,292 KB
testcase_30 AC 60 ms
51,440 KB
testcase_31 AC 79 ms
53,276 KB
testcase_32 AC 58 ms
51,420 KB
testcase_33 AC 68 ms
50,328 KB
testcase_34 AC 59 ms
51,448 KB
testcase_35 AC 82 ms
54,012 KB
testcase_36 AC 80 ms
53,400 KB
testcase_37 AC 61 ms
51,468 KB
testcase_38 AC 64 ms
52,256 KB
testcase_39 AC 67 ms
52,144 KB
testcase_40 AC 83 ms
52,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No00000275_Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		double[] arr = Stream.of(br.readLine().split(" ")).mapToDouble(Double::parseDouble).toArray();
		Arrays.sort(arr);
		if(n % 2 == 0) {
			System.out.println((arr[(n / 2) - 1] + arr[n / 2]) / 2);
		} else {
			System.out.println(arr[n / 2]);
		}
	}
}
0