結果

問題 No.275 中央値を求めよ
ユーザー spacenautspacenaut
提出日時 2016-05-15 10:23:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 194 ms / 1,000 ms
コード長 487 bytes
コンパイル時間 3,402 ms
コンパイル使用メモリ 73,564 KB
実行使用メモリ 56,416 KB
最終ジャッジ日時 2023-09-07 05:22:26
合計ジャッジ時間 10,703 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,776 KB
testcase_01 AC 126 ms
55,900 KB
testcase_02 AC 142 ms
55,876 KB
testcase_03 AC 126 ms
56,216 KB
testcase_04 AC 128 ms
56,044 KB
testcase_05 AC 129 ms
56,416 KB
testcase_06 AC 138 ms
56,168 KB
testcase_07 AC 188 ms
56,092 KB
testcase_08 AC 144 ms
55,528 KB
testcase_09 AC 146 ms
55,708 KB
testcase_10 AC 145 ms
55,996 KB
testcase_11 AC 125 ms
56,092 KB
testcase_12 AC 126 ms
55,956 KB
testcase_13 AC 126 ms
55,708 KB
testcase_14 AC 125 ms
55,812 KB
testcase_15 AC 193 ms
56,100 KB
testcase_16 AC 191 ms
56,228 KB
testcase_17 AC 191 ms
56,144 KB
testcase_18 AC 156 ms
55,888 KB
testcase_19 AC 189 ms
56,208 KB
testcase_20 AC 180 ms
56,072 KB
testcase_21 AC 157 ms
56,200 KB
testcase_22 AC 190 ms
56,096 KB
testcase_23 AC 162 ms
56,016 KB
testcase_24 AC 156 ms
55,516 KB
testcase_25 AC 191 ms
56,104 KB
testcase_26 AC 190 ms
55,824 KB
testcase_27 AC 189 ms
55,856 KB
testcase_28 AC 135 ms
56,196 KB
testcase_29 AC 161 ms
55,920 KB
testcase_30 AC 139 ms
55,952 KB
testcase_31 AC 193 ms
56,224 KB
testcase_32 AC 147 ms
55,724 KB
testcase_33 AC 189 ms
56,040 KB
testcase_34 AC 140 ms
56,036 KB
testcase_35 AC 184 ms
55,712 KB
testcase_36 AC 178 ms
56,192 KB
testcase_37 AC 149 ms
55,524 KB
testcase_38 AC 157 ms
55,828 KB
testcase_39 AC 154 ms
55,796 KB
testcase_40 AC 194 ms
56,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class No0275{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> array = new ArrayList<Integer>();
		
		int n = sc.nextInt();
		
		for(int i = 0; i < n; i++){
			array.add(sc.nextInt());
		}
		
		Collections.sort(array);
		
		double mid;
		if(n % 2 == 1){
			System.out.println(array.get(n / 2));
		}else{
			mid = ((double)(array.get(n / 2) + (double)array.get(n / 2 - 1)) / 2);
			System.out.println(mid);
		}
	}
}
0