結果

問題 No.275 中央値を求めよ
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-05-11 04:39:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 291 ms / 1,000 ms
コード長 547 bytes
コンパイル時間 3,770 ms
コンパイル使用メモリ 73,280 KB
実行使用メモリ 61,336 KB
最終ジャッジ日時 2023-09-07 07:09:31
合計ジャッジ時間 13,615 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
55,844 KB
testcase_01 AC 140 ms
56,100 KB
testcase_02 AC 173 ms
56,840 KB
testcase_03 AC 140 ms
55,808 KB
testcase_04 AC 143 ms
55,648 KB
testcase_05 AC 144 ms
55,760 KB
testcase_06 AC 172 ms
56,144 KB
testcase_07 AC 240 ms
60,536 KB
testcase_08 AC 203 ms
56,668 KB
testcase_09 AC 205 ms
56,208 KB
testcase_10 AC 211 ms
56,828 KB
testcase_11 AC 137 ms
55,860 KB
testcase_12 AC 139 ms
55,800 KB
testcase_13 AC 139 ms
56,232 KB
testcase_14 AC 140 ms
55,772 KB
testcase_15 AC 263 ms
61,108 KB
testcase_16 AC 260 ms
60,988 KB
testcase_17 AC 261 ms
61,220 KB
testcase_18 AC 223 ms
59,000 KB
testcase_19 AC 241 ms
60,932 KB
testcase_20 AC 243 ms
59,416 KB
testcase_21 AC 224 ms
60,064 KB
testcase_22 AC 248 ms
61,028 KB
testcase_23 AC 221 ms
60,084 KB
testcase_24 AC 207 ms
60,164 KB
testcase_25 AC 261 ms
61,040 KB
testcase_26 AC 241 ms
61,204 KB
testcase_27 AC 242 ms
60,236 KB
testcase_28 AC 161 ms
56,068 KB
testcase_29 AC 228 ms
60,156 KB
testcase_30 AC 174 ms
56,172 KB
testcase_31 AC 257 ms
61,108 KB
testcase_32 AC 206 ms
56,736 KB
testcase_33 AC 291 ms
60,984 KB
testcase_34 AC 179 ms
56,160 KB
testcase_35 AC 253 ms
60,964 KB
testcase_36 AC 229 ms
59,832 KB
testcase_37 AC 204 ms
54,072 KB
testcase_38 AC 220 ms
59,340 KB
testcase_39 AC 213 ms
60,096 KB
testcase_40 AC 263 ms
61,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Arrays;

public class GetMed{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double[] A = new double[N];
        for(int i=0; i<N; i++){
            A[i] = sc.nextDouble();
        }
        Arrays.sort(A);
        if(N%2 == 0){
            System.out.println((A[N/2-1]+A[N/2])/2);
        }else{
            System.out.println(A[(N-1)/2]);
        }
    }
}

0