結果

問題 No.275 中央値を求めよ
ユーザー kazapyon27kazapyon27
提出日時 2017-05-06 00:59:41
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 558 bytes
コンパイル時間 3,487 ms
コンパイル使用メモリ 72,672 KB
実行使用メモリ 58,512 KB
最終ジャッジ日時 2023-10-12 10:58:21
合計ジャッジ時間 10,985 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,920 KB
testcase_01 AC 124 ms
56,212 KB
testcase_02 AC 136 ms
56,128 KB
testcase_03 AC 121 ms
56,008 KB
testcase_04 AC 122 ms
56,140 KB
testcase_05 AC 123 ms
56,064 KB
testcase_06 AC 132 ms
55,740 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 124 ms
56,368 KB
testcase_12 AC 124 ms
56,256 KB
testcase_13 AC 125 ms
55,988 KB
testcase_14 AC 123 ms
56,356 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 134 ms
55,772 KB
testcase_29 WA -
testcase_30 AC 133 ms
56,048 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 135 ms
56,036 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

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(byte 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