結果

問題 No.275 中央値を求めよ
ユーザー kazapyon27kazapyon27
提出日時 2017-05-06 01:18:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 206 ms / 1,000 ms
コード長 559 bytes
コンパイル時間 3,412 ms
コンパイル使用メモリ 72,436 KB
実行使用メモリ 58,000 KB
最終ジャッジ日時 2023-09-07 06:04:10
合計ジャッジ時間 11,760 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,844 KB
testcase_01 AC 129 ms
56,384 KB
testcase_02 AC 141 ms
54,048 KB
testcase_03 AC 131 ms
55,596 KB
testcase_04 AC 131 ms
53,800 KB
testcase_05 AC 131 ms
55,592 KB
testcase_06 AC 139 ms
55,840 KB
testcase_07 AC 206 ms
56,140 KB
testcase_08 AC 153 ms
55,932 KB
testcase_09 AC 146 ms
55,948 KB
testcase_10 AC 149 ms
54,344 KB
testcase_11 AC 131 ms
55,956 KB
testcase_12 AC 135 ms
55,856 KB
testcase_13 AC 126 ms
55,940 KB
testcase_14 AC 131 ms
55,940 KB
testcase_15 AC 194 ms
56,232 KB
testcase_16 AC 191 ms
55,816 KB
testcase_17 AC 182 ms
56,116 KB
testcase_18 AC 162 ms
55,792 KB
testcase_19 AC 194 ms
56,504 KB
testcase_20 AC 194 ms
56,176 KB
testcase_21 AC 181 ms
56,288 KB
testcase_22 AC 187 ms
56,644 KB
testcase_23 AC 182 ms
55,780 KB
testcase_24 AC 156 ms
56,160 KB
testcase_25 AC 194 ms
56,352 KB
testcase_26 AC 182 ms
58,000 KB
testcase_27 AC 187 ms
56,060 KB
testcase_28 AC 139 ms
56,068 KB
testcase_29 AC 163 ms
56,376 KB
testcase_30 AC 139 ms
55,792 KB
testcase_31 AC 197 ms
56,748 KB
testcase_32 AC 146 ms
55,820 KB
testcase_33 AC 191 ms
56,636 KB
testcase_34 AC 145 ms
55,848 KB
testcase_35 AC 191 ms
56,204 KB
testcase_36 AC 194 ms
56,080 KB
testcase_37 AC 146 ms
55,600 KB
testcase_38 AC 156 ms
56,184 KB
testcase_39 AC 155 ms
55,596 KB
testcase_40 AC 196 ms
56,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*No.275 中央値を求めよ*/
import java.util.*;
public class No275 {
    public static void main(String[] args) {
    	short N;
    	float median;
		try(Scanner input =new Scanner(System.in)){
			N=input.nextShort();
			short data []= new short[N];
			for(short i=0;i<data.length;i++){
				data[i]=input.nextShort();
			}
			Arrays.sort(data);
			if(N%2!=0){
				median=data[data.length/2];
			}else{
				median=(data[data.length/2]+data[data.length/2-1])/2f;
			}
			System.out.println(median);
		}catch(Exception e){
			e.printStackTrace();
		}
    }
}
0