結果

問題 No.275 中央値を求めよ
ユーザー kanotownkanotown
提出日時 2018-12-14 16:09:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 186 ms / 1,000 ms
コード長 588 bytes
コンパイル時間 3,079 ms
コンパイル使用メモリ 75,216 KB
実行使用メモリ 58,228 KB
最終ジャッジ日時 2023-10-25 10:09:04
合計ジャッジ時間 11,177 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
57,512 KB
testcase_01 AC 126 ms
57,404 KB
testcase_02 AC 138 ms
57,648 KB
testcase_03 AC 127 ms
57,456 KB
testcase_04 AC 123 ms
57,104 KB
testcase_05 AC 119 ms
57,440 KB
testcase_06 AC 135 ms
57,628 KB
testcase_07 AC 176 ms
57,572 KB
testcase_08 AC 143 ms
57,524 KB
testcase_09 AC 145 ms
57,792 KB
testcase_10 AC 143 ms
57,528 KB
testcase_11 AC 112 ms
56,364 KB
testcase_12 AC 122 ms
57,388 KB
testcase_13 AC 121 ms
57,344 KB
testcase_14 AC 127 ms
57,344 KB
testcase_15 AC 179 ms
58,228 KB
testcase_16 AC 178 ms
57,692 KB
testcase_17 AC 182 ms
57,564 KB
testcase_18 AC 166 ms
57,560 KB
testcase_19 AC 177 ms
57,628 KB
testcase_20 AC 172 ms
57,652 KB
testcase_21 AC 166 ms
57,536 KB
testcase_22 AC 178 ms
57,660 KB
testcase_23 AC 169 ms
57,580 KB
testcase_24 AC 149 ms
57,248 KB
testcase_25 AC 176 ms
57,636 KB
testcase_26 AC 173 ms
57,588 KB
testcase_27 AC 174 ms
57,644 KB
testcase_28 AC 135 ms
57,036 KB
testcase_29 AC 169 ms
57,668 KB
testcase_30 AC 133 ms
56,988 KB
testcase_31 AC 181 ms
57,676 KB
testcase_32 AC 141 ms
57,532 KB
testcase_33 AC 186 ms
57,728 KB
testcase_34 AC 140 ms
56,944 KB
testcase_35 AC 173 ms
57,592 KB
testcase_36 AC 168 ms
57,616 KB
testcase_37 AC 134 ms
56,992 KB
testcase_38 AC 153 ms
57,308 KB
testcase_39 AC 159 ms
57,596 KB
testcase_40 AC 186 ms
57,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;
public class No275 {
    public static void main(String[] args) {
        // 標準入力
        Scanner sc = new Scanner(System.in);
            
        int n = sc.nextInt();
        int[] a = new int[n];
        float result;
        
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        
        if (n % 2 == 0) {
            result = (a[n / 2] + a[n / 2 - 1]) / 2.0f;
        } else {
            result = a[n / 2];
        }
        System.out.println(result);
    }
}
0