結果

問題 No.275 中央値を求めよ
ユーザー mits58mits58
提出日時 2016-05-05 14:25:10
言語 Java19
(openjdk 21)
結果
AC  
実行時間 192 ms / 1,000 ms
コード長 507 bytes
コンパイル時間 2,865 ms
コンパイル使用メモリ 72,436 KB
実行使用メモリ 57,228 KB
最終ジャッジ日時 2023-09-07 05:21:08
合計ジャッジ時間 11,305 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
55,748 KB
testcase_01 AC 128 ms
55,840 KB
testcase_02 AC 140 ms
56,008 KB
testcase_03 AC 128 ms
55,796 KB
testcase_04 AC 127 ms
56,116 KB
testcase_05 AC 126 ms
54,184 KB
testcase_06 AC 135 ms
55,792 KB
testcase_07 AC 184 ms
56,140 KB
testcase_08 AC 144 ms
56,132 KB
testcase_09 AC 145 ms
56,084 KB
testcase_10 AC 143 ms
55,876 KB
testcase_11 AC 124 ms
55,824 KB
testcase_12 AC 123 ms
56,372 KB
testcase_13 AC 125 ms
56,284 KB
testcase_14 AC 124 ms
55,844 KB
testcase_15 AC 190 ms
56,228 KB
testcase_16 AC 191 ms
56,508 KB
testcase_17 AC 185 ms
57,112 KB
testcase_18 AC 150 ms
55,780 KB
testcase_19 AC 182 ms
56,252 KB
testcase_20 AC 184 ms
56,728 KB
testcase_21 AC 156 ms
56,272 KB
testcase_22 AC 184 ms
56,148 KB
testcase_23 AC 176 ms
56,188 KB
testcase_24 AC 149 ms
55,892 KB
testcase_25 AC 188 ms
56,056 KB
testcase_26 AC 188 ms
56,140 KB
testcase_27 AC 183 ms
56,120 KB
testcase_28 AC 137 ms
56,116 KB
testcase_29 AC 160 ms
56,088 KB
testcase_30 AC 137 ms
55,496 KB
testcase_31 AC 180 ms
55,820 KB
testcase_32 AC 141 ms
56,140 KB
testcase_33 AC 181 ms
55,808 KB
testcase_34 AC 137 ms
56,100 KB
testcase_35 AC 183 ms
56,212 KB
testcase_36 AC 175 ms
56,280 KB
testcase_37 AC 143 ms
56,048 KB
testcase_38 AC 157 ms
55,956 KB
testcase_39 AC 155 ms
55,968 KB
testcase_40 AC 192 ms
57,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

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