結果

問題 No.275 中央値を求めよ
ユーザー aaaaasatoriaaaaasatori
提出日時 2018-02-05 09:16:14
言語 Java19
(openjdk 19.0.1)
結果
AC  
実行時間 194 ms / 1,000 ms
コード長 565 bytes
コンパイル時間 3,545 ms
実行使用メモリ 41,068 KB
最終ジャッジ日時 2023-01-22 22:52:42
合計ジャッジ時間 9,771 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
37,488 KB
testcase_01 AC 95 ms
37,792 KB
testcase_02 AC 100 ms
37,748 KB
testcase_03 AC 92 ms
37,612 KB
testcase_04 AC 95 ms
37,496 KB
testcase_05 AC 91 ms
37,712 KB
testcase_06 AC 106 ms
37,996 KB
testcase_07 AC 135 ms
39,000 KB
testcase_08 AC 108 ms
37,688 KB
testcase_09 AC 108 ms
37,608 KB
testcase_10 AC 113 ms
37,736 KB
testcase_11 AC 92 ms
37,356 KB
testcase_12 AC 91 ms
37,628 KB
testcase_13 AC 94 ms
37,508 KB
testcase_14 AC 92 ms
37,544 KB
testcase_15 AC 172 ms
40,464 KB
testcase_16 AC 182 ms
40,868 KB
testcase_17 AC 194 ms
40,828 KB
testcase_18 AC 120 ms
38,188 KB
testcase_19 AC 137 ms
38,964 KB
testcase_20 AC 162 ms
39,240 KB
testcase_21 AC 123 ms
38,340 KB
testcase_22 AC 166 ms
39,512 KB
testcase_23 AC 131 ms
38,748 KB
testcase_24 AC 114 ms
38,136 KB
testcase_25 AC 189 ms
41,068 KB
testcase_26 AC 146 ms
39,208 KB
testcase_27 AC 148 ms
39,132 KB
testcase_28 AC 102 ms
37,528 KB
testcase_29 AC 122 ms
38,576 KB
testcase_30 AC 102 ms
37,564 KB
testcase_31 AC 154 ms
39,452 KB
testcase_32 AC 109 ms
37,612 KB
testcase_33 AC 187 ms
40,480 KB
testcase_34 AC 99 ms
37,564 KB
testcase_35 AC 155 ms
39,068 KB
testcase_36 AC 129 ms
38,708 KB
testcase_37 AC 103 ms
37,800 KB
testcase_38 AC 113 ms
37,892 KB
testcase_39 AC 113 ms
37,724 KB
testcase_40 AC 173 ms
41,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No275 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); // 整数の個数
		int t[] = new int[n];
		int x; //交換用
		
		for(int i = 0;i < n;i++) {
			t[i] = sc.nextInt();
		}
		
		for(int i = 0;i < n;i++) {
			for(int j = i + 1;j < n;j++) {
				if(t[i] > t[j]) {
					x = t[i];
					t[i] = t[j];
					t[j] = x;
				}
			}
		}
		
		if(n % 2 == 1) {
			System.out.println(t[n / 2]);
		}else {
			System.out.println(((float)t[n / 2] + t[(n / 2) - 1]) / 2);
		}
	}
}
0