結果

問題 No.275 中央値を求めよ
ユーザー h_tyokinuhatah_tyokinuhata
提出日時 2016-01-19 19:00:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 192 ms / 1,000 ms
コード長 390 bytes
コンパイル時間 2,153 ms
コンパイル使用メモリ 71,732 KB
実行使用メモリ 56,740 KB
最終ジャッジ日時 2023-09-07 05:10:30
合計ジャッジ時間 10,372 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,000 KB
testcase_01 AC 126 ms
56,088 KB
testcase_02 AC 142 ms
55,864 KB
testcase_03 AC 129 ms
55,516 KB
testcase_04 AC 128 ms
56,196 KB
testcase_05 AC 127 ms
55,548 KB
testcase_06 AC 135 ms
55,492 KB
testcase_07 AC 178 ms
56,188 KB
testcase_08 AC 142 ms
55,892 KB
testcase_09 AC 144 ms
56,128 KB
testcase_10 AC 145 ms
55,792 KB
testcase_11 AC 127 ms
55,856 KB
testcase_12 AC 126 ms
56,176 KB
testcase_13 AC 125 ms
56,272 KB
testcase_14 AC 126 ms
55,944 KB
testcase_15 AC 191 ms
55,984 KB
testcase_16 AC 189 ms
56,440 KB
testcase_17 AC 192 ms
56,596 KB
testcase_18 AC 157 ms
56,156 KB
testcase_19 AC 189 ms
55,952 KB
testcase_20 AC 189 ms
56,740 KB
testcase_21 AC 168 ms
56,016 KB
testcase_22 AC 187 ms
55,996 KB
testcase_23 AC 182 ms
56,248 KB
testcase_24 AC 153 ms
55,560 KB
testcase_25 AC 188 ms
56,244 KB
testcase_26 AC 184 ms
55,900 KB
testcase_27 AC 183 ms
56,092 KB
testcase_28 AC 135 ms
55,800 KB
testcase_29 AC 186 ms
56,396 KB
testcase_30 AC 138 ms
56,060 KB
testcase_31 AC 190 ms
56,188 KB
testcase_32 AC 146 ms
56,112 KB
testcase_33 AC 183 ms
56,440 KB
testcase_34 AC 137 ms
53,924 KB
testcase_35 AC 180 ms
55,804 KB
testcase_36 AC 172 ms
55,984 KB
testcase_37 AC 145 ms
55,680 KB
testcase_38 AC 153 ms
55,660 KB
testcase_39 AC 154 ms
56,080 KB
testcase_40 AC 189 ms
55,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {

	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();
		}
		
		Arrays.sort(A);
		
		if(N % 2 == 0) {
			System.out.println((double)(A[N / 2] + A[N / 2 - 1]) / 2);
		} else {
			System.out.println(A[N / 2]);
		}
	}
}
0