結果

問題 No.275 中央値を求めよ
ユーザー 2ch_GreenApple2ch_GreenApple
提出日時 2015-09-06 09:13:06
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 509 bytes
コンパイル時間 4,745 ms
コンパイル使用メモリ 71,128 KB
実行使用メモリ 56,936 KB
最終ジャッジ日時 2023-09-26 09:20:49
合計ジャッジ時間 11,490 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,712 KB
testcase_01 AC 125 ms
55,964 KB
testcase_02 AC 141 ms
55,924 KB
testcase_03 AC 125 ms
55,404 KB
testcase_04 AC 124 ms
55,724 KB
testcase_05 AC 125 ms
55,740 KB
testcase_06 AC 135 ms
55,616 KB
testcase_07 AC 175 ms
55,676 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 146 ms
55,648 KB
testcase_11 RE -
testcase_12 AC 126 ms
55,816 KB
testcase_13 AC 128 ms
55,648 KB
testcase_14 AC 128 ms
55,740 KB
testcase_15 AC 192 ms
55,844 KB
testcase_16 AC 190 ms
56,084 KB
testcase_17 AC 189 ms
55,816 KB
testcase_18 AC 154 ms
55,600 KB
testcase_19 WA -
testcase_20 AC 178 ms
56,860 KB
testcase_21 AC 168 ms
55,908 KB
testcase_22 AC 189 ms
55,952 KB
testcase_23 WA -
testcase_24 AC 154 ms
55,412 KB
testcase_25 AC 189 ms
56,056 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 188 ms
55,672 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 142 ms
56,672 KB
testcase_38 AC 152 ms
55,632 KB
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);

            int a = sc.nextInt();
            double []b = new double[a];
            for (int i=0;i<a;i++){
                b[i]=sc.nextInt();
            }
            Arrays.sort(b);
            if (a%2==1){
                System.out.println(b[a%2]);
            }else {
                System.out.println((b[a/2]+b[a/2-1])/2);
        }
    }
}
0