結果

問題 No.275 中央値を求めよ
ユーザー aaaaasatoriaaaaasatori
提出日時 2018-02-05 09:16:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 205 ms / 1,000 ms
コード長 565 bytes
コンパイル時間 3,440 ms
コンパイル使用メモリ 71,716 KB
実行使用メモリ 57,732 KB
最終ジャッジ日時 2023-09-07 06:26:43
合計ジャッジ時間 11,688 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,844 KB
testcase_01 AC 127 ms
57,648 KB
testcase_02 AC 141 ms
55,380 KB
testcase_03 AC 127 ms
55,436 KB
testcase_04 AC 127 ms
55,616 KB
testcase_05 AC 125 ms
55,388 KB
testcase_06 AC 136 ms
53,352 KB
testcase_07 AC 192 ms
55,968 KB
testcase_08 AC 146 ms
55,380 KB
testcase_09 AC 143 ms
55,596 KB
testcase_10 AC 146 ms
55,384 KB
testcase_11 AC 125 ms
55,748 KB
testcase_12 AC 125 ms
55,524 KB
testcase_13 AC 125 ms
55,568 KB
testcase_14 AC 127 ms
55,764 KB
testcase_15 AC 201 ms
56,388 KB
testcase_16 AC 202 ms
56,036 KB
testcase_17 AC 200 ms
56,516 KB
testcase_18 AC 155 ms
55,828 KB
testcase_19 AC 193 ms
56,004 KB
testcase_20 AC 196 ms
56,232 KB
testcase_21 AC 173 ms
55,924 KB
testcase_22 AC 198 ms
55,940 KB
testcase_23 AC 164 ms
55,928 KB
testcase_24 AC 155 ms
55,508 KB
testcase_25 AC 205 ms
56,032 KB
testcase_26 AC 199 ms
56,424 KB
testcase_27 AC 196 ms
55,940 KB
testcase_28 AC 135 ms
55,668 KB
testcase_29 AC 157 ms
55,736 KB
testcase_30 AC 136 ms
55,424 KB
testcase_31 AC 197 ms
56,140 KB
testcase_32 AC 144 ms
55,348 KB
testcase_33 AC 199 ms
56,072 KB
testcase_34 AC 137 ms
55,384 KB
testcase_35 AC 195 ms
56,252 KB
testcase_36 AC 179 ms
57,732 KB
testcase_37 AC 147 ms
55,616 KB
testcase_38 AC 156 ms
55,952 KB
testcase_39 AC 156 ms
55,500 KB
testcase_40 AC 201 ms
55,824 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