結果

問題 No.275 中央値を求めよ
ユーザー ぴろずぴろず
提出日時 2015-09-04 22:43:53
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 415 bytes
コンパイル時間 2,186 ms
コンパイル使用メモリ 71,576 KB
実行使用メモリ 57,700 KB
最終ジャッジ日時 2023-09-26 06:03:31
合計ジャッジ時間 11,123 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,748 KB
testcase_01 AC 139 ms
57,404 KB
testcase_02 AC 143 ms
55,920 KB
testcase_03 WA -
testcase_04 AC 127 ms
56,136 KB
testcase_05 AC 133 ms
55,656 KB
testcase_06 AC 144 ms
55,816 KB
testcase_07 AC 187 ms
56,048 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 142 ms
55,704 KB
testcase_11 RE -
testcase_12 AC 130 ms
55,708 KB
testcase_13 WA -
testcase_14 AC 138 ms
55,644 KB
testcase_15 AC 200 ms
56,772 KB
testcase_16 AC 200 ms
54,456 KB
testcase_17 AC 201 ms
55,836 KB
testcase_18 AC 162 ms
55,708 KB
testcase_19 WA -
testcase_20 AC 187 ms
56,248 KB
testcase_21 AC 166 ms
54,292 KB
testcase_22 AC 191 ms
56,388 KB
testcase_23 WA -
testcase_24 AC 158 ms
56,076 KB
testcase_25 AC 192 ms
55,724 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 164 ms
56,184 KB
testcase_30 AC 141 ms
55,924 KB
testcase_31 AC 188 ms
56,208 KB
testcase_32 AC 154 ms
55,668 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 146 ms
55,756 KB
testcase_38 AC 158 ms
56,188 KB
testcase_39 WA -
testcase_40 AC 200 ms
56,252 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+1]);
		}else{
			System.out.println((a[n/2] + a[n/2-1]) / 2);
		}
	}

}
0