結果

問題 No.275 中央値を求めよ
ユーザー kuramubonnkuramubonn
提出日時 2023-02-01 20:58:13
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 175 ms / 1,000 ms
コード長 531 bytes
コンパイル時間 1,835 ms
使用メモリ 41,620 KB
最終ジャッジ日時 2023-02-01 20:58:22
合計ジャッジ時間 9,435 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 99 ms
38,068 KB
testcase_01 AC 106 ms
38,148 KB
testcase_02 AC 111 ms
38,256 KB
testcase_03 AC 103 ms
38,072 KB
testcase_04 AC 117 ms
38,052 KB
testcase_05 AC 102 ms
38,196 KB
testcase_06 AC 106 ms
38,076 KB
testcase_07 AC 140 ms
39,176 KB
testcase_08 AC 115 ms
37,900 KB
testcase_09 AC 122 ms
38,256 KB
testcase_10 AC 125 ms
38,416 KB
testcase_11 AC 102 ms
37,860 KB
testcase_12 AC 108 ms
38,004 KB
testcase_13 AC 126 ms
37,956 KB
testcase_14 AC 104 ms
38,112 KB
testcase_15 AC 175 ms
41,620 KB
testcase_16 AC 155 ms
39,748 KB
testcase_17 AC 156 ms
39,764 KB
testcase_18 AC 129 ms
38,804 KB
testcase_19 AC 140 ms
39,124 KB
testcase_20 AC 150 ms
39,336 KB
testcase_21 AC 151 ms
38,680 KB
testcase_22 AC 148 ms
39,516 KB
testcase_23 AC 138 ms
38,808 KB
testcase_24 AC 119 ms
38,704 KB
testcase_25 AC 167 ms
39,956 KB
testcase_26 AC 146 ms
39,168 KB
testcase_27 AC 143 ms
39,288 KB
testcase_28 AC 117 ms
38,272 KB
testcase_29 AC 137 ms
38,936 KB
testcase_30 AC 108 ms
38,108 KB
testcase_31 AC 156 ms
39,744 KB
testcase_32 AC 118 ms
38,052 KB
testcase_33 AC 155 ms
41,012 KB
testcase_34 AC 110 ms
38,368 KB
testcase_35 AC 143 ms
39,116 KB
testcase_36 AC 133 ms
39,028 KB
testcase_37 AC 130 ms
38,060 KB
testcase_38 AC 120 ms
38,316 KB
testcase_39 AC 125 ms
38,264 KB
testcase_40 AC 146 ms
39,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		
		for(int i = 0 ; i < num ; i++)list.add(sc.nextInt());
		
		Collections.sort(list);
		
		if(num % 2 == 0) {
			System.out.println((float)(list.get(num / 2 ) + (list.get(num / 2 - 1) )) / 2);
		}else {
			System.out.println(list.get(num / 2 ));
		}
	}
}
0