結果

問題 No.275 中央値を求めよ
ユーザー KinoshitaKinoshita
提出日時 2015-09-06 13:27:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 198 ms / 1,000 ms
コード長 476 bytes
コンパイル時間 3,096 ms
コンパイル使用メモリ 71,316 KB
実行使用メモリ 57,996 KB
最終ジャッジ日時 2023-09-07 04:39:38
合計ジャッジ時間 10,439 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,600 KB
testcase_01 AC 127 ms
55,596 KB
testcase_02 AC 141 ms
55,816 KB
testcase_03 AC 127 ms
55,768 KB
testcase_04 AC 126 ms
56,080 KB
testcase_05 AC 128 ms
55,560 KB
testcase_06 AC 138 ms
55,812 KB
testcase_07 AC 188 ms
56,188 KB
testcase_08 AC 143 ms
56,232 KB
testcase_09 AC 145 ms
55,860 KB
testcase_10 AC 144 ms
56,072 KB
testcase_11 AC 127 ms
55,564 KB
testcase_12 AC 126 ms
55,808 KB
testcase_13 AC 127 ms
55,784 KB
testcase_14 AC 129 ms
55,816 KB
testcase_15 AC 191 ms
56,244 KB
testcase_16 AC 190 ms
56,796 KB
testcase_17 AC 198 ms
56,656 KB
testcase_18 AC 159 ms
56,100 KB
testcase_19 AC 194 ms
56,648 KB
testcase_20 AC 192 ms
55,948 KB
testcase_21 AC 185 ms
56,736 KB
testcase_22 AC 191 ms
54,620 KB
testcase_23 AC 160 ms
56,112 KB
testcase_24 AC 153 ms
56,152 KB
testcase_25 AC 193 ms
56,696 KB
testcase_26 AC 189 ms
56,296 KB
testcase_27 AC 189 ms
56,272 KB
testcase_28 AC 138 ms
55,968 KB
testcase_29 AC 170 ms
57,996 KB
testcase_30 AC 140 ms
53,544 KB
testcase_31 AC 192 ms
56,612 KB
testcase_32 AC 148 ms
55,996 KB
testcase_33 AC 190 ms
56,968 KB
testcase_34 AC 140 ms
55,804 KB
testcase_35 AC 192 ms
56,816 KB
testcase_36 AC 169 ms
56,236 KB
testcase_37 AC 143 ms
55,904 KB
testcase_38 AC 157 ms
55,772 KB
testcase_39 AC 154 ms
56,112 KB
testcase_40 AC 198 ms
56,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main{
	
	static Main byakko = new Main();
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args){
		
		int n = sc.nextInt();
		double[] x = new double[n];
		
		for(int i = 0; i < n; i++){
			x[i] = sc.nextInt();
		}
		Arrays.sort(x);
		
		if(n % 2 == 0){
			System.out.println((x[n / 2] + x[n / 2 - 1]) / 2);
		}
		else{
			System.out.println(x[n / 2]);
		}
		
		sc.close();
	}
}
0