結果

問題 No.275 中央値を求めよ
ユーザー aaaaasatoriaaaaasatori
提出日時 2018-02-05 09:13:24
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 564 bytes
コンパイル時間 4,742 ms
コンパイル使用メモリ 72,432 KB
実行使用メモリ 56,548 KB
最終ジャッジ日時 2023-09-20 16:36:56
合計ジャッジ時間 11,108 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 122 ms
55,740 KB
testcase_04 AC 122 ms
55,648 KB
testcase_05 WA -
testcase_06 AC 135 ms
55,860 KB
testcase_07 AC 183 ms
56,140 KB
testcase_08 AC 138 ms
55,884 KB
testcase_09 AC 138 ms
55,500 KB
testcase_10 WA -
testcase_11 AC 121 ms
55,560 KB
testcase_12 AC 121 ms
55,844 KB
testcase_13 AC 122 ms
55,732 KB
testcase_14 AC 122 ms
55,816 KB
testcase_15 WA -
testcase_16 AC 193 ms
56,484 KB
testcase_17 AC 193 ms
54,532 KB
testcase_18 WA -
testcase_19 AC 185 ms
56,208 KB
testcase_20 AC 188 ms
55,956 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 169 ms
56,104 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 193 ms
54,920 KB
testcase_27 AC 195 ms
56,220 KB
testcase_28 AC 133 ms
55,916 KB
testcase_29 AC 172 ms
56,044 KB
testcase_30 AC 132 ms
55,756 KB
testcase_31 AC 191 ms
56,024 KB
testcase_32 AC 139 ms
55,772 KB
testcase_33 AC 191 ms
56,332 KB
testcase_34 AC 132 ms
55,700 KB
testcase_35 AC 192 ms
56,488 KB
testcase_36 AC 170 ms
56,132 KB
testcase_37 AC 138 ms
55,368 KB
testcase_38 AC 153 ms
55,880 KB
testcase_39 AC 148 ms
55,712 KB
testcase_40 AC 197 ms
56,356 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