結果

問題 No.275 中央値を求めよ
ユーザー papipenpapipen
提出日時 2017-03-26 00:28:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 198 ms / 1,000 ms
コード長 383 bytes
コンパイル時間 2,309 ms
コンパイル使用メモリ 71,560 KB
実行使用メモリ 58,072 KB
最終ジャッジ日時 2023-09-07 05:59:42
合計ジャッジ時間 10,480 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,856 KB
testcase_01 AC 127 ms
55,852 KB
testcase_02 AC 142 ms
58,064 KB
testcase_03 AC 128 ms
55,928 KB
testcase_04 AC 129 ms
56,016 KB
testcase_05 AC 130 ms
55,592 KB
testcase_06 AC 141 ms
55,960 KB
testcase_07 AC 190 ms
56,160 KB
testcase_08 AC 149 ms
55,792 KB
testcase_09 AC 151 ms
56,036 KB
testcase_10 AC 149 ms
55,848 KB
testcase_11 AC 130 ms
55,724 KB
testcase_12 AC 128 ms
56,072 KB
testcase_13 AC 132 ms
55,840 KB
testcase_14 AC 129 ms
55,584 KB
testcase_15 AC 198 ms
55,840 KB
testcase_16 AC 192 ms
56,268 KB
testcase_17 AC 194 ms
57,024 KB
testcase_18 AC 161 ms
56,036 KB
testcase_19 AC 188 ms
54,236 KB
testcase_20 AC 187 ms
56,220 KB
testcase_21 AC 180 ms
56,476 KB
testcase_22 AC 191 ms
56,268 KB
testcase_23 AC 185 ms
56,056 KB
testcase_24 AC 155 ms
55,940 KB
testcase_25 AC 190 ms
55,940 KB
testcase_26 AC 187 ms
56,136 KB
testcase_27 AC 186 ms
56,196 KB
testcase_28 AC 137 ms
55,848 KB
testcase_29 AC 171 ms
56,088 KB
testcase_30 AC 140 ms
55,920 KB
testcase_31 AC 184 ms
56,212 KB
testcase_32 AC 145 ms
53,776 KB
testcase_33 AC 189 ms
58,072 KB
testcase_34 AC 141 ms
56,172 KB
testcase_35 AC 187 ms
55,880 KB
testcase_36 AC 171 ms
56,060 KB
testcase_37 AC 147 ms
55,796 KB
testcase_38 AC 158 ms
55,908 KB
testcase_39 AC 153 ms
55,676 KB
testcase_40 AC 188 ms
56,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

class Tyuo{
	public static void main(String args[]){
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int a[] = new int[N];
		for(int i = 0; i < N; i++){
			a[i] = s.nextInt();
		}
		Arrays.sort(a);
		if(N % 2 != 0){
			System.out.println(a[N/2]);
		}else{
			System.out.println((a[(N/2)-1] + a[N/2]) / 2.0);
		}
}
}
0