結果

問題 No.275 中央値を求めよ
ユーザー ohagi_1182ohagi_1182
提出日時 2017-10-14 11:56:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 190 ms / 1,000 ms
コード長 464 bytes
コンパイル時間 2,685 ms
コンパイル使用メモリ 72,776 KB
実行使用メモリ 57,840 KB
最終ジャッジ日時 2023-09-07 06:18:59
合計ジャッジ時間 10,342 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,672 KB
testcase_01 AC 127 ms
56,172 KB
testcase_02 AC 143 ms
55,760 KB
testcase_03 AC 126 ms
56,156 KB
testcase_04 AC 127 ms
56,148 KB
testcase_05 AC 127 ms
56,180 KB
testcase_06 AC 138 ms
56,288 KB
testcase_07 AC 185 ms
56,036 KB
testcase_08 AC 146 ms
55,896 KB
testcase_09 AC 145 ms
55,756 KB
testcase_10 AC 145 ms
56,144 KB
testcase_11 AC 125 ms
55,896 KB
testcase_12 AC 127 ms
53,964 KB
testcase_13 AC 128 ms
55,928 KB
testcase_14 AC 127 ms
56,196 KB
testcase_15 AC 190 ms
56,040 KB
testcase_16 AC 188 ms
56,272 KB
testcase_17 AC 190 ms
56,924 KB
testcase_18 AC 158 ms
56,252 KB
testcase_19 AC 186 ms
56,400 KB
testcase_20 AC 188 ms
56,304 KB
testcase_21 AC 167 ms
54,784 KB
testcase_22 AC 190 ms
56,180 KB
testcase_23 AC 160 ms
56,136 KB
testcase_24 AC 154 ms
56,084 KB
testcase_25 AC 188 ms
56,076 KB
testcase_26 AC 187 ms
56,172 KB
testcase_27 AC 185 ms
56,856 KB
testcase_28 AC 136 ms
55,732 KB
testcase_29 AC 158 ms
56,328 KB
testcase_30 AC 136 ms
56,040 KB
testcase_31 AC 178 ms
56,516 KB
testcase_32 AC 144 ms
56,068 KB
testcase_33 AC 190 ms
55,568 KB
testcase_34 AC 138 ms
55,864 KB
testcase_35 AC 177 ms
56,028 KB
testcase_36 AC 160 ms
56,192 KB
testcase_37 AC 145 ms
57,840 KB
testcase_38 AC 154 ms
55,892 KB
testcase_39 AC 155 ms
56,236 KB
testcase_40 AC 189 ms
56,404 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);
		int n = sc.nextInt();
		int[] a = new int[n];
		int ans = 0;
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int center = (n - 1) / 2;
		if(a.length % 2 == 0) {
			System.out.println((a[center] + a[center + 1]) / 2.0);
		} else {
			System.out.println(a[center]);
		}

 	}
}
0