結果

問題 No.275 中央値を求めよ
ユーザー villachvillach
提出日時 2017-10-13 16:05:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 200 ms / 1,000 ms
コード長 523 bytes
コンパイル時間 3,441 ms
コンパイル使用メモリ 80,408 KB
実行使用メモリ 58,496 KB
最終ジャッジ日時 2023-09-07 06:18:28
合計ジャッジ時間 11,612 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,532 KB
testcase_01 AC 125 ms
55,588 KB
testcase_02 AC 144 ms
55,656 KB
testcase_03 AC 123 ms
55,284 KB
testcase_04 AC 125 ms
55,500 KB
testcase_05 AC 125 ms
55,604 KB
testcase_06 AC 136 ms
55,528 KB
testcase_07 AC 182 ms
55,720 KB
testcase_08 AC 143 ms
55,676 KB
testcase_09 AC 140 ms
55,584 KB
testcase_10 AC 151 ms
55,640 KB
testcase_11 AC 122 ms
55,436 KB
testcase_12 AC 122 ms
55,412 KB
testcase_13 AC 123 ms
55,344 KB
testcase_14 AC 129 ms
55,352 KB
testcase_15 AC 194 ms
58,496 KB
testcase_16 AC 191 ms
55,996 KB
testcase_17 AC 176 ms
56,432 KB
testcase_18 AC 156 ms
55,580 KB
testcase_19 AC 190 ms
55,720 KB
testcase_20 AC 184 ms
56,576 KB
testcase_21 AC 155 ms
55,840 KB
testcase_22 AC 188 ms
55,896 KB
testcase_23 AC 182 ms
56,360 KB
testcase_24 AC 158 ms
55,680 KB
testcase_25 AC 194 ms
56,268 KB
testcase_26 AC 193 ms
55,552 KB
testcase_27 AC 185 ms
55,740 KB
testcase_28 AC 131 ms
55,444 KB
testcase_29 AC 158 ms
55,880 KB
testcase_30 AC 137 ms
55,636 KB
testcase_31 AC 183 ms
55,808 KB
testcase_32 AC 142 ms
55,612 KB
testcase_33 AC 189 ms
56,240 KB
testcase_34 AC 136 ms
55,748 KB
testcase_35 AC 194 ms
55,872 KB
testcase_36 AC 184 ms
55,816 KB
testcase_37 AC 146 ms
55,540 KB
testcase_38 AC 156 ms
55,876 KB
testcase_39 AC 156 ms
55,752 KB
testcase_40 AC 200 ms
55,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class N275 {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> hoge = new ArrayList<Integer>();
		int n = sc.nextInt();
		for(int i = 0; i < n; ++i){
			hoge.add(sc.nextInt());
		}
		Collections.sort(hoge);
		if(n % 2 == 1){
			System.out.println(hoge.get(n / 2));
		}else{
			System.out.println((double) (hoge.get(n / 2) + hoge.get(n / 2 - 1)) / 2);
		}
	}
}
0