結果

問題 No.275 中央値を求めよ
ユーザー oyafusooyafuso
提出日時 2019-03-11 16:58:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 163 ms / 1,000 ms
コード長 878 bytes
コンパイル時間 2,088 ms
コンパイル使用メモリ 72,924 KB
実行使用メモリ 56,452 KB
最終ジャッジ日時 2023-09-05 20:13:36
合計ジャッジ時間 9,367 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
53,820 KB
testcase_01 AC 123 ms
53,888 KB
testcase_02 AC 124 ms
53,348 KB
testcase_03 AC 123 ms
55,956 KB
testcase_04 AC 122 ms
55,936 KB
testcase_05 AC 121 ms
56,196 KB
testcase_06 AC 124 ms
55,708 KB
testcase_07 AC 138 ms
56,452 KB
testcase_08 AC 125 ms
56,024 KB
testcase_09 AC 124 ms
55,680 KB
testcase_10 AC 124 ms
56,168 KB
testcase_11 AC 120 ms
55,676 KB
testcase_12 AC 121 ms
56,040 KB
testcase_13 AC 121 ms
55,516 KB
testcase_14 AC 119 ms
55,804 KB
testcase_15 AC 163 ms
55,956 KB
testcase_16 AC 154 ms
55,960 KB
testcase_17 AC 160 ms
55,732 KB
testcase_18 AC 136 ms
56,028 KB
testcase_19 AC 140 ms
55,996 KB
testcase_20 AC 140 ms
55,972 KB
testcase_21 AC 135 ms
56,004 KB
testcase_22 AC 140 ms
55,700 KB
testcase_23 AC 144 ms
56,148 KB
testcase_24 AC 133 ms
55,852 KB
testcase_25 AC 143 ms
55,552 KB
testcase_26 AC 141 ms
55,740 KB
testcase_27 AC 140 ms
56,176 KB
testcase_28 AC 125 ms
55,928 KB
testcase_29 AC 137 ms
56,132 KB
testcase_30 AC 124 ms
55,804 KB
testcase_31 AC 142 ms
55,564 KB
testcase_32 AC 128 ms
55,660 KB
testcase_33 AC 143 ms
55,560 KB
testcase_34 AC 126 ms
55,964 KB
testcase_35 AC 143 ms
56,056 KB
testcase_36 AC 140 ms
55,672 KB
testcase_37 AC 131 ms
55,592 KB
testcase_38 AC 135 ms
55,528 KB
testcase_39 AC 137 ms
55,712 KB
testcase_40 AC 160 ms
55,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {

	private static final String SPLIT_STR = " ";

	public static void main(String[] args) {
		// Scanner生成
		Scanner sc = new Scanner(System.in);
		// 入力設定
		String input = sc.nextLine();
		sc.reset();
		input = sc.nextLine();
		String[] split = input.split(SPLIT_STR);
		List<Integer> numList = new ArrayList<>(split.length);
		for (int i = 0; i < split.length; i++) {
			numList.add(Integer.parseInt(split[i]));
		}
		// Scannerクローズ
		sc.close();

		/* メイン処理開始 */
		// 変数初期化
		double result = 0;
		int middleIndex = numList.size() / 2;
		// 結果設定
		Collections.sort(numList);
		result = numList.get(middleIndex);
		if (numList.size() % 2 == 0) {
			result += numList.get(middleIndex - 1);
			result /= 2;
		}
		/* メイン処理終了 */

		// 結果出力
		System.out.println(result);
	}
}
0