結果

問題 No.275 中央値を求めよ
ユーザー gomagoma
提出日時 2017-09-19 22:09:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 191 ms / 1,000 ms
コード長 442 bytes
コンパイル時間 2,243 ms
コンパイル使用メモリ 72,116 KB
実行使用メモリ 57,960 KB
最終ジャッジ日時 2023-09-07 06:15:44
合計ジャッジ時間 9,964 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,888 KB
testcase_01 AC 123 ms
55,912 KB
testcase_02 AC 134 ms
55,804 KB
testcase_03 AC 125 ms
55,764 KB
testcase_04 AC 125 ms
55,856 KB
testcase_05 AC 123 ms
56,276 KB
testcase_06 AC 135 ms
55,980 KB
testcase_07 AC 182 ms
56,208 KB
testcase_08 AC 141 ms
53,908 KB
testcase_09 AC 141 ms
55,904 KB
testcase_10 AC 142 ms
55,816 KB
testcase_11 AC 123 ms
56,132 KB
testcase_12 AC 124 ms
56,116 KB
testcase_13 AC 125 ms
55,732 KB
testcase_14 AC 124 ms
56,196 KB
testcase_15 AC 189 ms
56,700 KB
testcase_16 AC 191 ms
56,216 KB
testcase_17 AC 186 ms
55,992 KB
testcase_18 AC 153 ms
56,036 KB
testcase_19 AC 172 ms
56,208 KB
testcase_20 AC 179 ms
56,176 KB
testcase_21 AC 160 ms
56,064 KB
testcase_22 AC 185 ms
55,976 KB
testcase_23 AC 171 ms
56,408 KB
testcase_24 AC 152 ms
56,144 KB
testcase_25 AC 187 ms
56,476 KB
testcase_26 AC 185 ms
56,920 KB
testcase_27 AC 182 ms
56,380 KB
testcase_28 AC 134 ms
55,960 KB
testcase_29 AC 175 ms
56,168 KB
testcase_30 AC 135 ms
55,988 KB
testcase_31 AC 181 ms
56,704 KB
testcase_32 AC 142 ms
55,532 KB
testcase_33 AC 174 ms
56,580 KB
testcase_34 AC 134 ms
56,288 KB
testcase_35 AC 178 ms
56,124 KB
testcase_36 AC 177 ms
56,220 KB
testcase_37 AC 141 ms
57,960 KB
testcase_38 AC 158 ms
55,912 KB
testcase_39 AC 158 ms
56,000 KB
testcase_40 AC 188 ms
56,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans[] = new int[n];

		for (int i = 0; i < n; i++) {
			ans[i] = sc.nextInt();
		}
		Arrays.sort(ans);
		if (n % 2 == 0) { // 奇数
			System.out.println((ans[(n / 2) - 1] + ans[n / 2]) / 2.0);
		} else { // 偶数
			System.out.println(ans[n / 2]);
		}
	}
}
0