結果

問題 No.275 中央値を求めよ
ユーザー S1hoS1ho
提出日時 2017-02-19 14:53:13
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 763 bytes
コンパイル時間 3,233 ms
コンパイル使用メモリ 75,892 KB
実行使用メモリ 58,876 KB
最終ジャッジ日時 2023-08-28 19:13:23
合計ジャッジ時間 11,550 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 118 ms
55,864 KB
testcase_04 AC 120 ms
56,548 KB
testcase_05 WA -
testcase_06 AC 129 ms
56,040 KB
testcase_07 AC 167 ms
56,204 KB
testcase_08 AC 133 ms
56,452 KB
testcase_09 AC 136 ms
56,000 KB
testcase_10 WA -
testcase_11 AC 118 ms
55,948 KB
testcase_12 AC 121 ms
56,128 KB
testcase_13 AC 117 ms
56,156 KB
testcase_14 AC 119 ms
55,936 KB
testcase_15 WA -
testcase_16 AC 185 ms
56,348 KB
testcase_17 AC 184 ms
56,820 KB
testcase_18 WA -
testcase_19 AC 173 ms
56,188 KB
testcase_20 AC 182 ms
56,704 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 168 ms
56,244 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 178 ms
56,160 KB
testcase_27 AC 175 ms
56,380 KB
testcase_28 AC 129 ms
56,188 KB
testcase_29 AC 159 ms
56,020 KB
testcase_30 AC 130 ms
56,092 KB
testcase_31 AC 182 ms
57,236 KB
testcase_32 AC 144 ms
56,216 KB
testcase_33 AC 179 ms
56,232 KB
testcase_34 AC 130 ms
56,124 KB
testcase_35 AC 163 ms
56,120 KB
testcase_36 AC 168 ms
56,304 KB
testcase_37 AC 136 ms
56,292 KB
testcase_38 AC 146 ms
56,496 KB
testcase_39 AC 143 ms
55,968 KB
testcase_40 AC 183 ms
56,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class CenterNum {

    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        
        int n = scanner.nextInt();
        
        ArrayList<Integer> list = new ArrayList();
        
        for(int i=0;i<n;i++){
            list.add(scanner.nextInt());
        }
        
        Collections.sort(list);
        
   
        if(list.size() % 2 == 0){
            float num = (list.get(list.size()/2 - 1) + list.get(list.size()/2)) / 2;
            System.out.println(String.format("%.1f", num));
        }else{
            int num = list.get(list.size()/2);
            System.out.println(num);
        }
    }
    
}
0