結果

問題 No.275 中央値を求めよ
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-08 22:38:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 198 ms / 1,000 ms
コード長 471 bytes
コンパイル時間 2,276 ms
コンパイル使用メモリ 72,152 KB
実行使用メモリ 58,712 KB
最終ジャッジ日時 2023-09-07 06:26:58
合計ジャッジ時間 10,292 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,712 KB
testcase_01 AC 130 ms
55,416 KB
testcase_02 AC 145 ms
55,716 KB
testcase_03 AC 130 ms
55,440 KB
testcase_04 AC 128 ms
56,164 KB
testcase_05 AC 128 ms
55,780 KB
testcase_06 AC 138 ms
55,852 KB
testcase_07 AC 188 ms
56,516 KB
testcase_08 AC 147 ms
56,044 KB
testcase_09 AC 146 ms
55,712 KB
testcase_10 AC 145 ms
55,648 KB
testcase_11 AC 127 ms
55,396 KB
testcase_12 AC 127 ms
55,828 KB
testcase_13 AC 127 ms
55,732 KB
testcase_14 AC 128 ms
56,032 KB
testcase_15 AC 198 ms
56,632 KB
testcase_16 AC 191 ms
56,244 KB
testcase_17 AC 195 ms
56,476 KB
testcase_18 AC 161 ms
55,624 KB
testcase_19 AC 192 ms
56,232 KB
testcase_20 AC 187 ms
56,248 KB
testcase_21 AC 157 ms
55,624 KB
testcase_22 AC 190 ms
56,244 KB
testcase_23 AC 167 ms
55,728 KB
testcase_24 AC 156 ms
55,620 KB
testcase_25 AC 191 ms
56,292 KB
testcase_26 AC 192 ms
55,888 KB
testcase_27 AC 190 ms
56,336 KB
testcase_28 AC 139 ms
55,952 KB
testcase_29 AC 175 ms
55,944 KB
testcase_30 AC 140 ms
55,452 KB
testcase_31 AC 194 ms
56,340 KB
testcase_32 AC 147 ms
55,840 KB
testcase_33 AC 191 ms
56,020 KB
testcase_34 AC 141 ms
55,428 KB
testcase_35 AC 190 ms
56,928 KB
testcase_36 AC 159 ms
55,832 KB
testcase_37 AC 147 ms
55,436 KB
testcase_38 AC 154 ms
55,852 KB
testcase_39 AC 155 ms
55,856 KB
testcase_40 AC 194 ms
58,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] ints = new int[n];
		for (int i=0; i<n; i++) {
			ints[i] = sc.nextInt();
		}
		Arrays.sort(ints);
		double ans = 0;
		if (ints.length%2==0) {
			double a = ints[ints.length/2];
			double b = ints[ints.length/2-1];
			ans = (a+b)/2;
		}
		else {
			ans = ints[ints.length/2];
		}
		System.out.println(ans);
	}
}
0