結果

問題 No.275 中央値を求めよ
ユーザー sasakkisasakki
提出日時 2016-04-26 11:50:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 180 ms / 1,000 ms
コード長 521 bytes
コンパイル時間 2,297 ms
コンパイル使用メモリ 73,472 KB
実行使用メモリ 58,300 KB
最終ジャッジ日時 2023-09-07 05:20:21
合計ジャッジ時間 10,141 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
56,092 KB
testcase_01 AC 122 ms
55,412 KB
testcase_02 AC 132 ms
55,712 KB
testcase_03 AC 123 ms
55,824 KB
testcase_04 AC 122 ms
55,776 KB
testcase_05 AC 123 ms
55,976 KB
testcase_06 AC 130 ms
56,028 KB
testcase_07 AC 173 ms
56,392 KB
testcase_08 AC 129 ms
55,984 KB
testcase_09 AC 130 ms
55,704 KB
testcase_10 AC 131 ms
56,056 KB
testcase_11 AC 121 ms
55,788 KB
testcase_12 AC 120 ms
55,904 KB
testcase_13 AC 121 ms
55,664 KB
testcase_14 AC 121 ms
56,036 KB
testcase_15 AC 180 ms
56,524 KB
testcase_16 AC 173 ms
55,912 KB
testcase_17 AC 176 ms
56,132 KB
testcase_18 AC 146 ms
56,240 KB
testcase_19 AC 173 ms
56,272 KB
testcase_20 AC 172 ms
56,372 KB
testcase_21 AC 144 ms
55,908 KB
testcase_22 AC 171 ms
56,484 KB
testcase_23 AC 166 ms
56,260 KB
testcase_24 AC 136 ms
55,780 KB
testcase_25 AC 170 ms
58,300 KB
testcase_26 AC 171 ms
56,156 KB
testcase_27 AC 170 ms
56,292 KB
testcase_28 AC 126 ms
56,252 KB
testcase_29 AC 145 ms
56,132 KB
testcase_30 AC 129 ms
55,500 KB
testcase_31 AC 170 ms
56,360 KB
testcase_32 AC 132 ms
55,964 KB
testcase_33 AC 172 ms
54,528 KB
testcase_34 AC 127 ms
56,172 KB
testcase_35 AC 173 ms
56,544 KB
testcase_36 AC 149 ms
55,944 KB
testcase_37 AC 129 ms
55,820 KB
testcase_38 AC 138 ms
55,832 KB
testcase_39 AC 141 ms
55,668 KB
testcase_40 AC 174 ms
56,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> array = new ArrayList<Integer>();
		
		int num = Integer.parseInt(sc.next());

		for(int i = 0; i < num; i++){
			array.add(Integer.parseInt(sc.next()));
		}

		Collections.sort(array);

		switch(num % 2){
		case 0:
			System.out.println( (double)(array.get(num / 2) + array.get((num / 2) - 1)) / 2 );
			break;
		case 1:
			System.out.println(array.get(num / 2));
			break;
		}
		
	}
}
0