結果

問題 No.275 中央値を求めよ
ユーザー kaoetayakaoetaya
提出日時 2016-11-29 19:55:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 202 ms / 1,000 ms
コード長 416 bytes
コンパイル時間 3,424 ms
コンパイル使用メモリ 72,596 KB
実行使用メモリ 58,540 KB
最終ジャッジ日時 2023-09-07 05:42:36
合計ジャッジ時間 11,822 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
55,684 KB
testcase_01 AC 129 ms
55,740 KB
testcase_02 AC 147 ms
56,020 KB
testcase_03 AC 131 ms
55,920 KB
testcase_04 AC 133 ms
55,844 KB
testcase_05 AC 130 ms
56,232 KB
testcase_06 AC 139 ms
55,976 KB
testcase_07 AC 191 ms
57,092 KB
testcase_08 AC 144 ms
55,808 KB
testcase_09 AC 145 ms
55,880 KB
testcase_10 AC 147 ms
56,092 KB
testcase_11 AC 126 ms
56,248 KB
testcase_12 AC 129 ms
56,260 KB
testcase_13 AC 126 ms
56,220 KB
testcase_14 AC 129 ms
55,872 KB
testcase_15 AC 197 ms
57,460 KB
testcase_16 AC 197 ms
58,540 KB
testcase_17 AC 200 ms
56,320 KB
testcase_18 AC 160 ms
56,308 KB
testcase_19 AC 174 ms
55,872 KB
testcase_20 AC 193 ms
57,124 KB
testcase_21 AC 161 ms
55,960 KB
testcase_22 AC 195 ms
56,212 KB
testcase_23 AC 169 ms
56,268 KB
testcase_24 AC 160 ms
56,068 KB
testcase_25 AC 202 ms
56,276 KB
testcase_26 AC 193 ms
55,692 KB
testcase_27 AC 179 ms
56,152 KB
testcase_28 AC 141 ms
57,760 KB
testcase_29 AC 184 ms
56,040 KB
testcase_30 AC 137 ms
55,900 KB
testcase_31 AC 191 ms
54,292 KB
testcase_32 AC 144 ms
55,876 KB
testcase_33 AC 186 ms
57,524 KB
testcase_34 AC 139 ms
56,024 KB
testcase_35 AC 187 ms
56,068 KB
testcase_36 AC 176 ms
56,176 KB
testcase_37 AC 147 ms
55,684 KB
testcase_38 AC 158 ms
55,668 KB
testcase_39 AC 160 ms
56,068 KB
testcase_40 AC 189 ms
56,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.math.*;

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