結果

問題 No.275 中央値を求めよ
ユーザー springspring
提出日時 2019-06-12 14:30:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 189 ms / 1,000 ms
コード長 675 bytes
コンパイル時間 2,477 ms
コンパイル使用メモリ 80,548 KB
実行使用メモリ 42,868 KB
最終ジャッジ日時 2024-04-18 17:50:18
合計ジャッジ時間 10,049 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
41,308 KB
testcase_01 AC 123 ms
41,796 KB
testcase_02 AC 149 ms
41,448 KB
testcase_03 AC 125 ms
41,156 KB
testcase_04 AC 127 ms
40,348 KB
testcase_05 AC 132 ms
41,412 KB
testcase_06 AC 138 ms
41,672 KB
testcase_07 AC 179 ms
42,368 KB
testcase_08 AC 148 ms
41,648 KB
testcase_09 AC 152 ms
41,564 KB
testcase_10 AC 146 ms
41,440 KB
testcase_11 AC 127 ms
41,500 KB
testcase_12 AC 126 ms
41,448 KB
testcase_13 AC 125 ms
41,576 KB
testcase_14 AC 128 ms
41,372 KB
testcase_15 AC 189 ms
42,516 KB
testcase_16 AC 184 ms
42,576 KB
testcase_17 AC 183 ms
42,452 KB
testcase_18 AC 158 ms
41,796 KB
testcase_19 AC 164 ms
42,448 KB
testcase_20 AC 179 ms
42,416 KB
testcase_21 AC 169 ms
42,184 KB
testcase_22 AC 177 ms
42,260 KB
testcase_23 AC 170 ms
42,004 KB
testcase_24 AC 159 ms
41,816 KB
testcase_25 AC 185 ms
42,632 KB
testcase_26 AC 180 ms
42,468 KB
testcase_27 AC 179 ms
42,276 KB
testcase_28 AC 135 ms
41,432 KB
testcase_29 AC 166 ms
42,032 KB
testcase_30 AC 135 ms
41,672 KB
testcase_31 AC 177 ms
42,620 KB
testcase_32 AC 144 ms
42,048 KB
testcase_33 AC 172 ms
42,652 KB
testcase_34 AC 135 ms
41,540 KB
testcase_35 AC 171 ms
42,148 KB
testcase_36 AC 171 ms
42,012 KB
testcase_37 AC 142 ms
41,860 KB
testcase_38 AC 161 ms
42,028 KB
testcase_39 AC 157 ms
41,740 KB
testcase_40 AC 183 ms
42,868 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