結果

問題 No.275 中央値を求めよ
ユーザー uafr_csuafr_cs
提出日時 2015-09-04 22:35:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 199 ms / 1,000 ms
コード長 525 bytes
コンパイル時間 2,137 ms
コンパイル使用メモリ 72,980 KB
実行使用メモリ 41,032 KB
最終ジャッジ日時 2023-09-07 04:35:17
合計ジャッジ時間 10,327 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
39,636 KB
testcase_01 AC 127 ms
39,692 KB
testcase_02 AC 141 ms
39,644 KB
testcase_03 AC 125 ms
39,880 KB
testcase_04 AC 132 ms
39,548 KB
testcase_05 AC 128 ms
39,432 KB
testcase_06 AC 137 ms
39,264 KB
testcase_07 AC 184 ms
40,944 KB
testcase_08 AC 138 ms
39,392 KB
testcase_09 AC 139 ms
40,252 KB
testcase_10 AC 147 ms
39,996 KB
testcase_11 AC 125 ms
39,644 KB
testcase_12 AC 126 ms
39,412 KB
testcase_13 AC 124 ms
39,712 KB
testcase_14 AC 128 ms
39,616 KB
testcase_15 AC 198 ms
40,840 KB
testcase_16 AC 199 ms
40,940 KB
testcase_17 AC 192 ms
40,636 KB
testcase_18 AC 158 ms
40,380 KB
testcase_19 AC 175 ms
40,828 KB
testcase_20 AC 194 ms
40,416 KB
testcase_21 AC 173 ms
40,464 KB
testcase_22 AC 197 ms
40,644 KB
testcase_23 AC 169 ms
40,224 KB
testcase_24 AC 155 ms
39,876 KB
testcase_25 AC 193 ms
40,868 KB
testcase_26 AC 196 ms
41,032 KB
testcase_27 AC 183 ms
40,188 KB
testcase_28 AC 136 ms
39,808 KB
testcase_29 AC 164 ms
40,132 KB
testcase_30 AC 133 ms
39,984 KB
testcase_31 AC 191 ms
40,844 KB
testcase_32 AC 142 ms
39,928 KB
testcase_33 AC 185 ms
40,560 KB
testcase_34 AC 138 ms
39,836 KB
testcase_35 AC 170 ms
40,856 KB
testcase_36 AC 182 ms
40,732 KB
testcase_37 AC 146 ms
39,944 KB
testcase_38 AC 152 ms
40,472 KB
testcase_39 AC 158 ms
39,860 KB
testcase_40 AC 186 ms
40,736 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