結果

問題 No.275 中央値を求めよ
ユーザー aaaaasatoriaaaaasatori
提出日時 2018-02-05 09:10:46
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 584 bytes
コンパイル時間 3,697 ms
コンパイル使用メモリ 71,636 KB
実行使用メモリ 58,268 KB
最終ジャッジ日時 2023-09-20 16:12:05
合計ジャッジ時間 11,820 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,008 KB
testcase_01 AC 121 ms
55,748 KB
testcase_02 AC 136 ms
56,088 KB
testcase_03 WA -
testcase_04 AC 121 ms
55,908 KB
testcase_05 AC 122 ms
55,868 KB
testcase_06 AC 131 ms
55,656 KB
testcase_07 AC 184 ms
56,732 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 143 ms
55,424 KB
testcase_11 RE -
testcase_12 AC 122 ms
55,684 KB
testcase_13 WA -
testcase_14 AC 122 ms
55,952 KB
testcase_15 AC 200 ms
56,624 KB
testcase_16 AC 196 ms
56,420 KB
testcase_17 AC 199 ms
56,280 KB
testcase_18 AC 155 ms
56,200 KB
testcase_19 WA -
testcase_20 AC 191 ms
56,440 KB
testcase_21 AC 155 ms
56,496 KB
testcase_22 AC 191 ms
56,576 KB
testcase_23 WA -
testcase_24 AC 150 ms
56,000 KB
testcase_25 AC 199 ms
56,544 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 162 ms
56,108 KB
testcase_30 AC 135 ms
55,844 KB
testcase_31 AC 198 ms
58,268 KB
testcase_32 AC 142 ms
55,868 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 142 ms
56,196 KB
testcase_38 AC 149 ms
55,536 KB
testcase_39 WA -
testcase_40 AC 197 ms
56,912 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 - 1) / 2 + 1]);
		}else {
			System.out.println((float)(t[(n - 1) / 2] + t[(n - 1) / 2 + 1]) / 2);
		}
	}
}
0