結果

問題 No.275 中央値を求めよ
ユーザー ぴろずぴろず
提出日時 2015-09-04 22:44:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 207 ms / 1,000 ms
コード長 413 bytes
コンパイル時間 2,800 ms
コンパイル使用メモリ 71,840 KB
実行使用メモリ 56,676 KB
最終ジャッジ日時 2023-09-07 04:35:37
合計ジャッジ時間 10,116 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,536 KB
testcase_01 AC 127 ms
55,496 KB
testcase_02 AC 140 ms
55,680 KB
testcase_03 AC 127 ms
55,680 KB
testcase_04 AC 126 ms
55,756 KB
testcase_05 AC 128 ms
55,844 KB
testcase_06 AC 138 ms
55,816 KB
testcase_07 AC 177 ms
56,516 KB
testcase_08 AC 145 ms
55,520 KB
testcase_09 AC 144 ms
55,788 KB
testcase_10 AC 147 ms
55,724 KB
testcase_11 AC 126 ms
55,812 KB
testcase_12 AC 126 ms
56,016 KB
testcase_13 AC 128 ms
55,768 KB
testcase_14 AC 128 ms
55,724 KB
testcase_15 AC 191 ms
56,024 KB
testcase_16 AC 196 ms
56,216 KB
testcase_17 AC 193 ms
56,100 KB
testcase_18 AC 161 ms
56,100 KB
testcase_19 AC 192 ms
56,400 KB
testcase_20 AC 187 ms
56,332 KB
testcase_21 AC 161 ms
56,000 KB
testcase_22 AC 207 ms
56,384 KB
testcase_23 AC 164 ms
56,176 KB
testcase_24 AC 157 ms
55,996 KB
testcase_25 AC 192 ms
56,028 KB
testcase_26 AC 188 ms
56,152 KB
testcase_27 AC 174 ms
56,088 KB
testcase_28 AC 136 ms
56,116 KB
testcase_29 AC 159 ms
56,112 KB
testcase_30 AC 140 ms
55,880 KB
testcase_31 AC 186 ms
56,676 KB
testcase_32 AC 144 ms
55,764 KB
testcase_33 AC 187 ms
54,016 KB
testcase_34 AC 140 ms
55,816 KB
testcase_35 AC 182 ms
56,060 KB
testcase_36 AC 172 ms
56,044 KB
testcase_37 AC 143 ms
55,812 KB
testcase_38 AC 154 ms
55,768 KB
testcase_39 AC 156 ms
56,076 KB
testcase_40 AC 191 ms
56,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no275;

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();
		double[] a = new double[n];
		for(int i=0;i<n;i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		if (n % 2 == 1) {
			System.out.println(a[n/2]);
		}else{
			System.out.println((a[n/2] + a[n/2-1]) / 2);
		}
	}

}
0