結果

問題 No.275 中央値を求めよ
ユーザー kaoetayakaoetaya
提出日時 2016-11-29 19:52:45
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 408 bytes
コンパイル時間 3,431 ms
コンパイル使用メモリ 75,500 KB
実行使用メモリ 43,016 KB
最終ジャッジ日時 2024-05-05 15:24:18
合計ジャッジ時間 10,804 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 103 ms
40,052 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 127 ms
41,808 KB
testcase_09 AC 130 ms
41,268 KB
testcase_10 RE -
testcase_11 AC 112 ms
41,340 KB
testcase_12 RE -
testcase_13 AC 122 ms
41,084 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 170 ms
42,368 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 163 ms
42,152 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 165 ms
42,472 KB
testcase_27 AC 163 ms
42,524 KB
testcase_28 AC 123 ms
41,468 KB
testcase_29 AC 157 ms
41,820 KB
testcase_30 AC 126 ms
41,280 KB
testcase_31 RE -
testcase_32 AC 149 ms
41,764 KB
testcase_33 AC 171 ms
42,368 KB
testcase_34 AC 128 ms
41,208 KB
testcase_35 AC 171 ms
42,292 KB
testcase_36 AC 154 ms
42,156 KB
testcase_37 RE -
testcase_38 RE -
testcase_39 AC 149 ms
41,856 KB
testcase_40 AC 173 ms
42,400 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",(num[n/2]+num[n/2-1])/2);
		
    }
}
0