結果

問題 No.275 中央値を求めよ
ユーザー AoiroFukurouAoiroFukurou
提出日時 2015-09-18 20:15:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 198 ms / 1,000 ms
コード長 516 bytes
コンパイル時間 4,015 ms
コンパイル使用メモリ 72,620 KB
実行使用メモリ 56,588 KB
最終ジャッジ日時 2023-09-07 04:46:30
合計ジャッジ時間 12,138 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,576 KB
testcase_01 AC 126 ms
55,748 KB
testcase_02 AC 139 ms
56,040 KB
testcase_03 AC 122 ms
55,780 KB
testcase_04 AC 128 ms
55,776 KB
testcase_05 AC 126 ms
55,712 KB
testcase_06 AC 137 ms
55,784 KB
testcase_07 AC 158 ms
56,376 KB
testcase_08 AC 144 ms
56,252 KB
testcase_09 AC 148 ms
55,820 KB
testcase_10 AC 145 ms
55,704 KB
testcase_11 AC 129 ms
55,856 KB
testcase_12 AC 126 ms
56,052 KB
testcase_13 AC 129 ms
55,632 KB
testcase_14 AC 128 ms
55,720 KB
testcase_15 AC 198 ms
56,588 KB
testcase_16 AC 192 ms
56,160 KB
testcase_17 AC 190 ms
56,080 KB
testcase_18 AC 155 ms
55,984 KB
testcase_19 AC 186 ms
56,008 KB
testcase_20 AC 183 ms
56,012 KB
testcase_21 AC 155 ms
56,300 KB
testcase_22 AC 186 ms
56,380 KB
testcase_23 AC 159 ms
55,920 KB
testcase_24 AC 154 ms
55,976 KB
testcase_25 AC 191 ms
56,096 KB
testcase_26 AC 187 ms
55,680 KB
testcase_27 AC 184 ms
55,684 KB
testcase_28 AC 136 ms
55,860 KB
testcase_29 AC 163 ms
56,344 KB
testcase_30 AC 135 ms
55,384 KB
testcase_31 AC 191 ms
56,284 KB
testcase_32 AC 145 ms
55,704 KB
testcase_33 AC 177 ms
56,428 KB
testcase_34 AC 136 ms
55,700 KB
testcase_35 AC 184 ms
56,504 KB
testcase_36 AC 183 ms
56,204 KB
testcase_37 AC 144 ms
55,932 KB
testcase_38 AC 152 ms
56,128 KB
testcase_39 AC 153 ms
55,716 KB
testcase_40 AC 191 ms
56,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yuki_coder;

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

public class No_275 {
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<a.length; i++){
		a[i] = sc.nextInt();
	}
	Arrays.sort(a);
	if(n%2==1){
		int b = (n+1)/2;
		System.out.println(a[b-1]);
	}else{
		double b = ((n+1.0)/2.0);
		int c = (int)((b - 0.5)-1);
		int d = (int)((b + 0.5)-1);
		double e = (a[c] + a[d])/2.0;
		System.out.println(e);
}
	}
}
0