結果

問題 No.275 中央値を求めよ
ユーザー r.suzukir.suzuki
提出日時 2015-12-08 18:07:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 210 ms / 1,000 ms
コード長 666 bytes
コンパイル時間 3,606 ms
コンパイル使用メモリ 71,800 KB
実行使用メモリ 56,988 KB
最終ジャッジ日時 2023-09-07 05:04:58
合計ジャッジ時間 12,092 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,788 KB
testcase_01 AC 125 ms
55,752 KB
testcase_02 AC 140 ms
55,508 KB
testcase_03 AC 127 ms
55,912 KB
testcase_04 AC 128 ms
56,240 KB
testcase_05 AC 127 ms
55,740 KB
testcase_06 AC 138 ms
55,736 KB
testcase_07 AC 194 ms
56,208 KB
testcase_08 AC 145 ms
56,364 KB
testcase_09 AC 144 ms
55,684 KB
testcase_10 AC 146 ms
55,764 KB
testcase_11 AC 128 ms
55,884 KB
testcase_12 AC 129 ms
55,436 KB
testcase_13 AC 127 ms
56,184 KB
testcase_14 AC 128 ms
55,492 KB
testcase_15 AC 207 ms
56,368 KB
testcase_16 AC 202 ms
55,900 KB
testcase_17 AC 210 ms
56,540 KB
testcase_18 AC 161 ms
55,984 KB
testcase_19 AC 194 ms
56,452 KB
testcase_20 AC 198 ms
56,988 KB
testcase_21 AC 160 ms
56,096 KB
testcase_22 AC 200 ms
55,988 KB
testcase_23 AC 161 ms
56,088 KB
testcase_24 AC 154 ms
54,040 KB
testcase_25 AC 201 ms
56,308 KB
testcase_26 AC 197 ms
56,364 KB
testcase_27 AC 200 ms
56,808 KB
testcase_28 AC 139 ms
55,824 KB
testcase_29 AC 167 ms
56,516 KB
testcase_30 AC 138 ms
55,752 KB
testcase_31 AC 194 ms
56,800 KB
testcase_32 AC 144 ms
55,892 KB
testcase_33 AC 202 ms
56,256 KB
testcase_34 AC 139 ms
55,900 KB
testcase_35 AC 196 ms
56,060 KB
testcase_36 AC 160 ms
56,336 KB
testcase_37 AC 149 ms
55,880 KB
testcase_38 AC 155 ms
55,940 KB
testcase_39 AC 157 ms
55,592 KB
testcase_40 AC 202 ms
56,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No_275 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		float[] F = new float[sc.nextInt()];

		for (int i = 0; i < F.length; i++) {
			F[i] = sc.nextInt();
		}

		for (int i = 0; i < F.length - 1; i++) {
			for (int j = i + 1; j < F.length; j++) {
				if (F[i] > F[j]) {
					float tmp = F[i];
					F[i] = F[j];
					F[j] = tmp;
				}
			}
		}

		System.out.println(lookForMedian(F));
		sc.close();
	}

	static float lookForMedian(float[] m) {
		int ml = m.length % 2;
		if (ml == 0) {
			return (m[m.length / 2 - 1] + m[m.length / 2]) / 2;
		} else {
			return m[m.length / 2];
		}
	}
}
0