結果

問題 No.275 中央値を求めよ
ユーザー len_discoreglen_discoreg
提出日時 2016-06-03 10:04:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 270 ms / 1,000 ms
コード長 477 bytes
コンパイル時間 5,509 ms
コンパイル使用メモリ 73,140 KB
実行使用メモリ 61,788 KB
最終ジャッジ日時 2023-09-07 05:24:44
合計ジャッジ時間 16,127 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
55,980 KB
testcase_01 AC 136 ms
56,320 KB
testcase_02 AC 182 ms
56,728 KB
testcase_03 AC 141 ms
56,464 KB
testcase_04 AC 139 ms
55,952 KB
testcase_05 AC 141 ms
56,364 KB
testcase_06 AC 164 ms
56,420 KB
testcase_07 AC 240 ms
59,724 KB
testcase_08 AC 197 ms
56,552 KB
testcase_09 AC 200 ms
56,784 KB
testcase_10 AC 199 ms
56,552 KB
testcase_11 AC 137 ms
55,700 KB
testcase_12 AC 138 ms
56,600 KB
testcase_13 AC 139 ms
56,276 KB
testcase_14 AC 139 ms
56,120 KB
testcase_15 AC 265 ms
61,492 KB
testcase_16 AC 263 ms
61,036 KB
testcase_17 AC 260 ms
61,756 KB
testcase_18 AC 224 ms
59,512 KB
testcase_19 AC 246 ms
60,076 KB
testcase_20 AC 251 ms
60,636 KB
testcase_21 AC 231 ms
60,752 KB
testcase_22 AC 257 ms
61,788 KB
testcase_23 AC 233 ms
60,088 KB
testcase_24 AC 212 ms
60,168 KB
testcase_25 AC 261 ms
61,592 KB
testcase_26 AC 244 ms
60,336 KB
testcase_27 AC 248 ms
60,380 KB
testcase_28 AC 164 ms
56,280 KB
testcase_29 AC 229 ms
60,032 KB
testcase_30 AC 166 ms
56,680 KB
testcase_31 AC 249 ms
61,096 KB
testcase_32 AC 197 ms
56,752 KB
testcase_33 AC 251 ms
61,316 KB
testcase_34 AC 169 ms
56,620 KB
testcase_35 AC 244 ms
60,688 KB
testcase_36 AC 222 ms
60,012 KB
testcase_37 AC 198 ms
56,916 KB
testcase_38 AC 221 ms
59,952 KB
testcase_39 AC 222 ms
60,260 KB
testcase_40 AC 270 ms
61,392 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