結果

問題 No.275 中央値を求めよ
ユーザー uafr_csuafr_cs
提出日時 2015-09-04 22:35:51
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 182 ms / 1,000 ms
コード長 525 bytes
コンパイル時間 1,825 ms
使用メモリ 41,436 KB
最終ジャッジ日時 2023-01-22 19:57:07
合計ジャッジ時間 8,821 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 100 ms
38,332 KB
testcase_01 AC 102 ms
38,092 KB
testcase_02 AC 110 ms
38,348 KB
testcase_03 AC 98 ms
37,460 KB
testcase_04 AC 103 ms
38,128 KB
testcase_05 AC 102 ms
38,376 KB
testcase_06 AC 104 ms
38,420 KB
testcase_07 AC 139 ms
39,196 KB
testcase_08 AC 112 ms
37,896 KB
testcase_09 AC 112 ms
37,904 KB
testcase_10 AC 118 ms
38,200 KB
testcase_11 AC 96 ms
37,652 KB
testcase_12 AC 104 ms
38,260 KB
testcase_13 AC 97 ms
37,652 KB
testcase_14 AC 103 ms
38,164 KB
testcase_15 AC 182 ms
41,160 KB
testcase_16 AC 169 ms
41,436 KB
testcase_17 AC 169 ms
41,164 KB
testcase_18 AC 124 ms
38,172 KB
testcase_19 AC 125 ms
38,448 KB
testcase_20 AC 147 ms
39,596 KB
testcase_21 AC 128 ms
38,716 KB
testcase_22 AC 151 ms
39,540 KB
testcase_23 AC 125 ms
38,784 KB
testcase_24 AC 122 ms
38,416 KB
testcase_25 AC 150 ms
40,948 KB
testcase_26 AC 140 ms
39,256 KB
testcase_27 AC 135 ms
40,560 KB
testcase_28 AC 106 ms
37,872 KB
testcase_29 AC 129 ms
38,180 KB
testcase_30 AC 106 ms
37,592 KB
testcase_31 AC 146 ms
40,812 KB
testcase_32 AC 112 ms
37,832 KB
testcase_33 AC 170 ms
40,824 KB
testcase_34 AC 110 ms
37,836 KB
testcase_35 AC 134 ms
38,936 KB
testcase_36 AC 126 ms
38,316 KB
testcase_37 AC 119 ms
38,524 KB
testcase_38 AC 120 ms
38,504 KB
testcase_39 AC 123 ms
38,048 KB
testcase_40 AC 144 ms
40,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		
		int[] arr = new int[N];
		for(int i = 0; i < N; i++){
			arr[i] = sc.nextInt();
		}
		
		Arrays.sort(arr);
		
		if(N % 2 == 0){
			System.out.printf("%.8f\n", (double)(arr[N / 2 - 1] + arr[N / 2]) / 2);
		}else{
			System.out.println(arr[N / 2]);
		}
	}

}
0