結果

問題 No.275 中央値を求めよ
ユーザー CavasiroCavasiro
提出日時 2020-04-15 01:43:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 200 ms / 1,000 ms
コード長 409 bytes
コンパイル時間 2,069 ms
コンパイル使用メモリ 75,652 KB
実行使用メモリ 54,972 KB
最終ジャッジ日時 2024-04-09 18:29:32
合計ジャッジ時間 10,110 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
54,040 KB
testcase_01 AC 133 ms
54,164 KB
testcase_02 AC 148 ms
54,376 KB
testcase_03 AC 135 ms
54,180 KB
testcase_04 AC 135 ms
54,316 KB
testcase_05 AC 135 ms
54,176 KB
testcase_06 AC 148 ms
54,232 KB
testcase_07 AC 179 ms
54,636 KB
testcase_08 AC 147 ms
54,332 KB
testcase_09 AC 147 ms
54,248 KB
testcase_10 AC 149 ms
54,164 KB
testcase_11 AC 132 ms
54,284 KB
testcase_12 AC 133 ms
54,368 KB
testcase_13 AC 130 ms
54,248 KB
testcase_14 AC 133 ms
54,240 KB
testcase_15 AC 194 ms
54,660 KB
testcase_16 AC 200 ms
54,820 KB
testcase_17 AC 195 ms
54,772 KB
testcase_18 AC 158 ms
54,420 KB
testcase_19 AC 185 ms
54,248 KB
testcase_20 AC 188 ms
54,472 KB
testcase_21 AC 166 ms
54,520 KB
testcase_22 AC 191 ms
54,420 KB
testcase_23 AC 168 ms
54,608 KB
testcase_24 AC 169 ms
54,424 KB
testcase_25 AC 189 ms
54,792 KB
testcase_26 AC 186 ms
54,584 KB
testcase_27 AC 184 ms
54,544 KB
testcase_28 AC 144 ms
54,308 KB
testcase_29 AC 167 ms
54,448 KB
testcase_30 AC 144 ms
54,220 KB
testcase_31 AC 178 ms
54,972 KB
testcase_32 AC 152 ms
54,344 KB
testcase_33 AC 182 ms
54,924 KB
testcase_34 AC 144 ms
54,448 KB
testcase_35 AC 183 ms
54,680 KB
testcase_36 AC 177 ms
54,508 KB
testcase_37 AC 145 ms
54,356 KB
testcase_38 AC 164 ms
54,464 KB
testcase_39 AC 159 ms
54,460 KB
testcase_40 AC 189 ms
54,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;
 
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = sc.nextInt();
		}
		double median;
		Arrays.sort(a);
		if(n%2==0){
			median = (a[n/2-1]+a[n/2])/2.0;
		} else {
			median = a[n/2];
		}
		System.out.printf("%.1f\n", median);
	}
}
0