結果

問題 No.275 中央値を求めよ
ユーザー ryosuke0825ryosuke0825
提出日時 2018-04-08 12:05:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 277 ms / 1,000 ms
コード長 543 bytes
コンパイル時間 4,397 ms
コンパイル使用メモリ 75,148 KB
実行使用メモリ 61,416 KB
最終ジャッジ日時 2023-09-07 06:51:40
合計ジャッジ時間 14,420 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
55,936 KB
testcase_01 AC 145 ms
55,656 KB
testcase_02 AC 185 ms
56,960 KB
testcase_03 AC 146 ms
55,848 KB
testcase_04 AC 144 ms
55,792 KB
testcase_05 AC 146 ms
55,628 KB
testcase_06 AC 179 ms
56,116 KB
testcase_07 AC 254 ms
60,656 KB
testcase_08 AC 220 ms
54,816 KB
testcase_09 AC 213 ms
56,948 KB
testcase_10 AC 218 ms
56,676 KB
testcase_11 AC 146 ms
56,012 KB
testcase_12 AC 142 ms
53,468 KB
testcase_13 AC 143 ms
55,756 KB
testcase_14 AC 143 ms
55,908 KB
testcase_15 AC 268 ms
61,224 KB
testcase_16 AC 277 ms
61,048 KB
testcase_17 AC 277 ms
61,124 KB
testcase_18 AC 242 ms
58,792 KB
testcase_19 AC 259 ms
59,664 KB
testcase_20 AC 261 ms
60,408 KB
testcase_21 AC 242 ms
60,204 KB
testcase_22 AC 270 ms
61,224 KB
testcase_23 AC 247 ms
60,724 KB
testcase_24 AC 225 ms
59,448 KB
testcase_25 AC 276 ms
60,876 KB
testcase_26 AC 271 ms
60,512 KB
testcase_27 AC 261 ms
59,668 KB
testcase_28 AC 180 ms
56,092 KB
testcase_29 AC 240 ms
60,104 KB
testcase_30 AC 169 ms
55,864 KB
testcase_31 AC 265 ms
60,296 KB
testcase_32 AC 212 ms
56,324 KB
testcase_33 AC 273 ms
60,592 KB
testcase_34 AC 177 ms
56,144 KB
testcase_35 AC 254 ms
59,916 KB
testcase_36 AC 230 ms
60,264 KB
testcase_37 AC 216 ms
56,180 KB
testcase_38 AC 212 ms
59,280 KB
testcase_39 AC 234 ms
59,488 KB
testcase_40 AC 276 ms
61,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No275 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Double> A = new ArrayList<Double>();

		for (double i = 1; i <= N; i++) {
			A.add(sc.nextDouble());
		}

		Collections.sort(A);

		if (A.size() % 2 == 0) {
			double d = ((A.get(A.size() / 2)) + (A.get((A.size() - 1) / 2))) / 2;
			System.out.println(d);
		} else {
			System.out.println(A.get(A.size() / 2));
		}
	}
}
0