結果

問題 No.275 中央値を求めよ
ユーザー TatsuDX
提出日時 2016-09-03 15:24:55
言語 Java
(openjdk 23)
結果
AC  
実行時間 190 ms / 1,000 ms
コード長 429 bytes
コンパイル時間 3,435 ms
コンパイル使用メモリ 74,744 KB
実行使用メモリ 42,752 KB
最終ジャッジ日時 2024-06-25 00:01:35
合計ジャッジ時間 11,417 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Test {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int num = sc.nextInt();
		int[] n = new int[num];
		for (int i = 0; i < num; i++) {
			n[i] = sc.nextInt();
		}
		Arrays.sort(n);
		if (num % 2 == 0) {
			System.out.println((double) (n[num / 2] + n[num / 2 - 1]) / 2);
		} else {
			System.out.println(n[num / 2]);
		}
	}
}
0