結果

問題 No.275 中央値を求めよ
ユーザー 🐧しゅんチャマ🌸🐧しゅんチャマ🌸
提出日時 2023-09-13 22:59:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 196 ms / 1,000 ms
コード長 675 bytes
コンパイル時間 2,148 ms
コンパイル使用メモリ 71,260 KB
実行使用メモリ 57,004 KB
最終ジャッジ日時 2023-09-13 22:59:32
合計ジャッジ時間 10,071 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,704 KB
testcase_01 AC 116 ms
55,980 KB
testcase_02 AC 134 ms
55,464 KB
testcase_03 AC 117 ms
56,172 KB
testcase_04 AC 119 ms
55,960 KB
testcase_05 AC 117 ms
56,276 KB
testcase_06 AC 128 ms
55,456 KB
testcase_07 AC 167 ms
56,172 KB
testcase_08 AC 133 ms
56,076 KB
testcase_09 AC 136 ms
56,028 KB
testcase_10 AC 138 ms
55,752 KB
testcase_11 AC 123 ms
53,692 KB
testcase_12 AC 120 ms
55,736 KB
testcase_13 AC 120 ms
56,392 KB
testcase_14 AC 121 ms
55,844 KB
testcase_15 AC 193 ms
56,516 KB
testcase_16 AC 196 ms
56,564 KB
testcase_17 AC 194 ms
56,272 KB
testcase_18 AC 155 ms
56,240 KB
testcase_19 AC 185 ms
56,252 KB
testcase_20 AC 194 ms
56,220 KB
testcase_21 AC 168 ms
56,312 KB
testcase_22 AC 187 ms
56,656 KB
testcase_23 AC 165 ms
56,280 KB
testcase_24 AC 146 ms
56,212 KB
testcase_25 AC 193 ms
56,424 KB
testcase_26 AC 189 ms
56,680 KB
testcase_27 AC 191 ms
56,636 KB
testcase_28 AC 129 ms
55,764 KB
testcase_29 AC 147 ms
56,380 KB
testcase_30 AC 134 ms
55,968 KB
testcase_31 AC 194 ms
56,636 KB
testcase_32 AC 136 ms
56,400 KB
testcase_33 AC 192 ms
56,580 KB
testcase_34 AC 130 ms
56,096 KB
testcase_35 AC 186 ms
57,004 KB
testcase_36 AC 168 ms
56,204 KB
testcase_37 AC 137 ms
53,616 KB
testcase_38 AC 144 ms
56,124 KB
testcase_39 AC 146 ms
54,104 KB
testcase_40 AC 189 ms
56,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Y275{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] A=new int[n];
        for(int i=0;i<n;i++){
            A[i]=sc.nextInt();
        }
        for(int i=0;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                if(A[i]>A[j]){
                    int tmp=A[i];
                    A[i]=A[j];
                    A[j]=tmp;
                }
            }
        }
        double ans;
        if(n%2==0){
            ans=(A[n/2-1]+A[n/2])/2.0;
            System.out.print(ans);
        }else{
            System.out.println(A[n/2]);
        }
    }
}
0