結果

問題 No.275 中央値を求めよ
ユーザー spacenautspacenaut
提出日時 2016-05-15 10:18:01
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 469 bytes
コンパイル時間 2,314 ms
コンパイル使用メモリ 76,256 KB
実行使用メモリ 56,052 KB
最終ジャッジ日時 2024-04-15 21:44:42
合計ジャッジ時間 9,189 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 125 ms
41,488 KB
testcase_04 AC 120 ms
41,412 KB
testcase_05 WA -
testcase_06 AC 125 ms
40,824 KB
testcase_07 AC 170 ms
42,112 KB
testcase_08 AC 136 ms
41,816 KB
testcase_09 AC 133 ms
41,740 KB
testcase_10 WA -
testcase_11 AC 124 ms
41,720 KB
testcase_12 AC 112 ms
40,276 KB
testcase_13 AC 107 ms
40,056 KB
testcase_14 AC 109 ms
39,976 KB
testcase_15 WA -
testcase_16 AC 175 ms
42,676 KB
testcase_17 AC 162 ms
42,692 KB
testcase_18 WA -
testcase_19 AC 171 ms
42,584 KB
testcase_20 AC 173 ms
42,524 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 150 ms
42,384 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 180 ms
42,752 KB
testcase_27 AC 175 ms
42,240 KB
testcase_28 AC 132 ms
41,536 KB
testcase_29 AC 161 ms
41,924 KB
testcase_30 AC 136 ms
41,536 KB
testcase_31 AC 176 ms
43,184 KB
testcase_32 AC 131 ms
41,592 KB
testcase_33 AC 170 ms
42,132 KB
testcase_34 AC 129 ms
41,856 KB
testcase_35 AC 171 ms
42,076 KB
testcase_36 AC 162 ms
41,872 KB
testcase_37 AC 131 ms
41,496 KB
testcase_38 AC 142 ms
41,644 KB
testcase_39 AC 157 ms
41,820 KB
testcase_40 AC 174 ms
42,648 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 = (array.get(n / 2) + array.get(n / 2 - 1)) / 2;
			System.out.println(mid);
		}
	}
}
0