結果

問題 No.275 中央値を求めよ
ユーザー len_proglen_prog
提出日時 2016-06-03 10:06:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 284 ms / 1,000 ms
コード長 477 bytes
コンパイル時間 4,351 ms
コンパイル使用メモリ 80,056 KB
実行使用メモリ 61,616 KB
最終ジャッジ日時 2023-09-07 05:25:54
合計ジャッジ時間 14,535 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
54,300 KB
testcase_01 AC 144 ms
56,132 KB
testcase_02 AC 192 ms
58,372 KB
testcase_03 AC 145 ms
56,072 KB
testcase_04 AC 142 ms
56,032 KB
testcase_05 AC 143 ms
56,140 KB
testcase_06 AC 178 ms
55,956 KB
testcase_07 AC 250 ms
60,604 KB
testcase_08 AC 222 ms
57,544 KB
testcase_09 AC 219 ms
57,820 KB
testcase_10 AC 222 ms
57,252 KB
testcase_11 AC 144 ms
56,212 KB
testcase_12 AC 143 ms
56,200 KB
testcase_13 AC 143 ms
56,188 KB
testcase_14 AC 144 ms
56,240 KB
testcase_15 AC 276 ms
61,516 KB
testcase_16 AC 284 ms
61,560 KB
testcase_17 AC 275 ms
61,616 KB
testcase_18 AC 237 ms
57,848 KB
testcase_19 AC 249 ms
60,992 KB
testcase_20 AC 257 ms
60,872 KB
testcase_21 AC 243 ms
59,904 KB
testcase_22 AC 270 ms
61,396 KB
testcase_23 AC 243 ms
60,608 KB
testcase_24 AC 229 ms
59,644 KB
testcase_25 AC 274 ms
61,384 KB
testcase_26 AC 268 ms
61,364 KB
testcase_27 AC 259 ms
60,696 KB
testcase_28 AC 171 ms
56,176 KB
testcase_29 AC 239 ms
60,884 KB
testcase_30 AC 169 ms
56,444 KB
testcase_31 AC 265 ms
61,528 KB
testcase_32 AC 205 ms
56,156 KB
testcase_33 AC 268 ms
61,608 KB
testcase_34 AC 184 ms
56,224 KB
testcase_35 AC 255 ms
60,776 KB
testcase_36 AC 241 ms
60,108 KB
testcase_37 AC 219 ms
57,724 KB
testcase_38 AC 216 ms
60,176 KB
testcase_39 AC 231 ms
60,024 KB
testcase_40 AC 272 ms
61,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Yuki275 {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		double[] arr = new double[N];

		for(int i = 0; i < N; i++){
			arr[i] = scan.nextDouble();
		}

		Arrays.sort(arr);

		double median = 0.0;
		if(N % 2 == 0){
			median = (arr[(N/2) - 1] + arr[N/2]) / 2;
		}else{
			median = Math.ceil(arr[N/2]);
		}
		System.out.printf("%.1f", median);
	}
}
0