結果

問題 No.275 中央値を求めよ
ユーザー YukimotoPGYukimotoPG
提出日時 2019-02-14 08:41:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 187 ms / 1,000 ms
コード長 386 bytes
コンパイル時間 2,909 ms
コンパイル使用メモリ 71,592 KB
実行使用メモリ 57,056 KB
最終ジャッジ日時 2023-10-11 12:29:43
合計ジャッジ時間 10,163 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,148 KB
testcase_01 AC 122 ms
56,280 KB
testcase_02 AC 136 ms
56,380 KB
testcase_03 AC 123 ms
55,728 KB
testcase_04 AC 122 ms
55,924 KB
testcase_05 AC 122 ms
55,956 KB
testcase_06 AC 134 ms
55,564 KB
testcase_07 AC 180 ms
56,268 KB
testcase_08 AC 138 ms
55,844 KB
testcase_09 AC 138 ms
56,388 KB
testcase_10 AC 139 ms
55,852 KB
testcase_11 AC 122 ms
55,788 KB
testcase_12 AC 124 ms
55,884 KB
testcase_13 AC 119 ms
55,712 KB
testcase_14 AC 117 ms
55,816 KB
testcase_15 AC 186 ms
57,056 KB
testcase_16 AC 187 ms
56,468 KB
testcase_17 AC 184 ms
56,400 KB
testcase_18 AC 149 ms
56,028 KB
testcase_19 AC 179 ms
56,512 KB
testcase_20 AC 170 ms
55,760 KB
testcase_21 AC 171 ms
55,804 KB
testcase_22 AC 182 ms
56,400 KB
testcase_23 AC 171 ms
56,156 KB
testcase_24 AC 144 ms
56,460 KB
testcase_25 AC 178 ms
56,116 KB
testcase_26 AC 180 ms
56,100 KB
testcase_27 AC 167 ms
56,300 KB
testcase_28 AC 132 ms
56,016 KB
testcase_29 AC 174 ms
56,144 KB
testcase_30 AC 131 ms
55,932 KB
testcase_31 AC 170 ms
56,132 KB
testcase_32 AC 139 ms
56,016 KB
testcase_33 AC 173 ms
55,836 KB
testcase_34 AC 130 ms
55,916 KB
testcase_35 AC 177 ms
56,312 KB
testcase_36 AC 166 ms
55,736 KB
testcase_37 AC 138 ms
55,908 KB
testcase_38 AC 156 ms
55,816 KB
testcase_39 AC 149 ms
56,304 KB
testcase_40 AC 180 ms
56,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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