結果

問題 No.275 中央値を求めよ
ユーザー ribenngeribennge
提出日時 2018-08-22 12:21:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 191 ms / 1,000 ms
コード長 470 bytes
コンパイル時間 2,173 ms
コンパイル使用メモリ 72,336 KB
実行使用メモリ 58,064 KB
最終ジャッジ日時 2023-09-07 07:35:05
合計ジャッジ時間 10,508 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,660 KB
testcase_01 AC 126 ms
55,656 KB
testcase_02 AC 139 ms
55,440 KB
testcase_03 AC 127 ms
55,792 KB
testcase_04 AC 126 ms
55,856 KB
testcase_05 AC 127 ms
55,892 KB
testcase_06 AC 134 ms
55,956 KB
testcase_07 AC 178 ms
55,948 KB
testcase_08 AC 143 ms
55,892 KB
testcase_09 AC 145 ms
56,164 KB
testcase_10 AC 146 ms
55,668 KB
testcase_11 AC 126 ms
55,656 KB
testcase_12 AC 125 ms
55,992 KB
testcase_13 AC 123 ms
56,228 KB
testcase_14 AC 125 ms
55,828 KB
testcase_15 AC 190 ms
56,128 KB
testcase_16 AC 191 ms
56,128 KB
testcase_17 AC 191 ms
56,012 KB
testcase_18 AC 163 ms
55,880 KB
testcase_19 AC 181 ms
55,936 KB
testcase_20 AC 183 ms
55,948 KB
testcase_21 AC 168 ms
58,064 KB
testcase_22 AC 185 ms
56,292 KB
testcase_23 AC 165 ms
56,096 KB
testcase_24 AC 152 ms
55,420 KB
testcase_25 AC 185 ms
56,392 KB
testcase_26 AC 185 ms
56,212 KB
testcase_27 AC 170 ms
56,028 KB
testcase_28 AC 135 ms
55,820 KB
testcase_29 AC 177 ms
55,844 KB
testcase_30 AC 135 ms
55,824 KB
testcase_31 AC 190 ms
56,704 KB
testcase_32 AC 142 ms
55,648 KB
testcase_33 AC 185 ms
56,464 KB
testcase_34 AC 145 ms
55,716 KB
testcase_35 AC 181 ms
56,256 KB
testcase_36 AC 171 ms
55,872 KB
testcase_37 AC 139 ms
55,580 KB
testcase_38 AC 158 ms
55,924 KB
testcase_39 AC 162 ms
55,968 KB
testcase_40 AC 190 ms
55,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.Arrays;

class No_275{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] ary = new int[n];
		double median;
		
		for(int i = 0;i <  n;i++){
		ary[i] = sc.nextInt();
		}
		
		Arrays.sort(ary);
		
		if(n % 2 == 0){
			median =(ary[n / 2] + ary[n / 2 - 1]) / 2.0;
		}else{
		median = ary[n / 2];
		}
		
		System.out.println(median);
		}
		}
		
0