結果

問題 No.275 中央値を求めよ
ユーザー springspring
提出日時 2019-06-12 14:30:42
言語 Java19
(openjdk 19.0.1)
結果
AC  
実行時間 183 ms / 1,000 ms
コード長 675 bytes
コンパイル時間 2,258 ms
コンパイル使用メモリ 73,960 KB
実行使用メモリ 58,180 KB
最終ジャッジ日時 2023-07-31 17:47:18
合計ジャッジ時間 10,251 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,888 KB
testcase_01 AC 116 ms
55,944 KB
testcase_02 AC 131 ms
55,860 KB
testcase_03 AC 118 ms
55,708 KB
testcase_04 AC 120 ms
56,584 KB
testcase_05 AC 119 ms
53,804 KB
testcase_06 AC 129 ms
56,604 KB
testcase_07 AC 174 ms
56,312 KB
testcase_08 AC 134 ms
56,136 KB
testcase_09 AC 133 ms
56,068 KB
testcase_10 AC 138 ms
56,780 KB
testcase_11 AC 118 ms
56,224 KB
testcase_12 AC 116 ms
56,068 KB
testcase_13 AC 115 ms
55,560 KB
testcase_14 AC 122 ms
53,840 KB
testcase_15 AC 180 ms
56,564 KB
testcase_16 AC 183 ms
56,436 KB
testcase_17 AC 173 ms
56,140 KB
testcase_18 AC 155 ms
56,112 KB
testcase_19 AC 182 ms
56,232 KB
testcase_20 AC 181 ms
56,088 KB
testcase_21 AC 169 ms
56,128 KB
testcase_22 AC 181 ms
56,296 KB
testcase_23 AC 173 ms
56,156 KB
testcase_24 AC 150 ms
56,320 KB
testcase_25 AC 181 ms
55,968 KB
testcase_26 AC 180 ms
56,812 KB
testcase_27 AC 183 ms
57,264 KB
testcase_28 AC 134 ms
56,416 KB
testcase_29 AC 169 ms
58,180 KB
testcase_30 AC 129 ms
56,352 KB
testcase_31 AC 180 ms
56,624 KB
testcase_32 AC 135 ms
55,560 KB
testcase_33 AC 170 ms
56,052 KB
testcase_34 AC 133 ms
56,116 KB
testcase_35 AC 164 ms
56,020 KB
testcase_36 AC 166 ms
56,076 KB
testcase_37 AC 141 ms
56,376 KB
testcase_38 AC 150 ms
55,872 KB
testcase_39 AC 143 ms
56,692 KB
testcase_40 AC 183 ms
55,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		ArrayList<Integer> numList = new ArrayList<Integer>();
		for(int i=0;i<count;i++){
			int inputNum = sc.nextInt();
			numList.add(inputNum);
		}
		sc.close();
		Collections.sort(numList);
		if(numList.size()%2!=0){
			System.out.println(numList.get(numList.size()/2));
		}else if(numList.size()%2==0){
			double result = (numList.get(numList.size()/2-1)+numList.get(numList.size()/2))/(double)2;
			System.out.println(result);
		}

	}// mainmethod

} // class
0