結果

問題 No.275 中央値を求めよ
ユーザー 37zigen37zigen
提出日時 2016-03-29 13:23:16
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 271 ms / 1,000 ms
コード長 450 bytes
コンパイル時間 2,234 ms
使用メモリ 47,380 KB
最終ジャッジ日時 2023-01-22 21:04:34
合計ジャッジ時間 11,354 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 106 ms
38,368 KB
testcase_01 AC 105 ms
38,260 KB
testcase_02 AC 130 ms
38,780 KB
testcase_03 AC 104 ms
38,292 KB
testcase_04 AC 109 ms
38,324 KB
testcase_05 AC 107 ms
38,396 KB
testcase_06 AC 123 ms
38,560 KB
testcase_07 AC 220 ms
43,008 KB
testcase_08 AC 137 ms
40,120 KB
testcase_09 AC 149 ms
39,996 KB
testcase_10 AC 145 ms
39,800 KB
testcase_11 AC 105 ms
38,160 KB
testcase_12 AC 108 ms
38,080 KB
testcase_13 AC 102 ms
38,416 KB
testcase_14 AC 111 ms
38,208 KB
testcase_15 AC 271 ms
47,380 KB
testcase_16 AC 260 ms
45,728 KB
testcase_17 AC 246 ms
45,348 KB
testcase_18 AC 179 ms
42,732 KB
testcase_19 AC 235 ms
44,576 KB
testcase_20 AC 249 ms
45,984 KB
testcase_21 AC 222 ms
45,528 KB
testcase_22 AC 258 ms
47,328 KB
testcase_23 AC 240 ms
43,364 KB
testcase_24 AC 158 ms
41,064 KB
testcase_25 AC 248 ms
47,332 KB
testcase_26 AC 258 ms
45,700 KB
testcase_27 AC 240 ms
44,856 KB
testcase_28 AC 121 ms
39,428 KB
testcase_29 AC 196 ms
42,872 KB
testcase_30 AC 123 ms
38,932 KB
testcase_31 AC 243 ms
45,836 KB
testcase_32 AC 139 ms
39,976 KB
testcase_33 AC 261 ms
46,476 KB
testcase_34 AC 121 ms
39,388 KB
testcase_35 AC 240 ms
46,092 KB
testcase_36 AC 237 ms
43,600 KB
testcase_37 AC 144 ms
39,760 KB
testcase_38 AC 156 ms
40,304 KB
testcase_39 AC 156 ms
41,116 KB
testcase_40 AC 269 ms
46,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder275;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		double[] a=new double[n+1];
		a[0]=-99999999;
		
		for(int i=1;i<=n;i++){
			a[i]=sc.nextDouble();
		}
		Arrays.sort(a);
		if(n%2==0){
			System.out.println((a[n/2]+a[n/2+1])/2);
		}else if(n%2==1){
			System.out.println(a[n/2+1]);
		}
		sc.close();
	}
}
0