結果

問題 No.275 中央値を求めよ
ユーザー fal_rndfal_rnd
提出日時 2017-04-02 21:12:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 193 ms / 1,000 ms
コード長 579 bytes
コンパイル時間 3,004 ms
コンパイル使用メモリ 72,200 KB
実行使用メモリ 56,652 KB
最終ジャッジ日時 2023-09-07 06:00:31
合計ジャッジ時間 10,245 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,724 KB
testcase_01 AC 121 ms
55,912 KB
testcase_02 AC 142 ms
56,104 KB
testcase_03 AC 123 ms
55,888 KB
testcase_04 AC 122 ms
55,992 KB
testcase_05 AC 121 ms
55,712 KB
testcase_06 AC 139 ms
56,328 KB
testcase_07 AC 166 ms
55,900 KB
testcase_08 AC 139 ms
54,372 KB
testcase_09 AC 140 ms
55,920 KB
testcase_10 AC 137 ms
56,204 KB
testcase_11 AC 123 ms
55,868 KB
testcase_12 AC 123 ms
56,248 KB
testcase_13 AC 126 ms
55,796 KB
testcase_14 AC 126 ms
56,236 KB
testcase_15 AC 191 ms
56,304 KB
testcase_16 AC 188 ms
56,152 KB
testcase_17 AC 189 ms
56,284 KB
testcase_18 AC 155 ms
56,096 KB
testcase_19 AC 182 ms
56,160 KB
testcase_20 AC 189 ms
55,940 KB
testcase_21 AC 166 ms
56,208 KB
testcase_22 AC 172 ms
56,484 KB
testcase_23 AC 157 ms
56,376 KB
testcase_24 AC 149 ms
56,044 KB
testcase_25 AC 185 ms
56,136 KB
testcase_26 AC 188 ms
56,208 KB
testcase_27 AC 183 ms
56,216 KB
testcase_28 AC 136 ms
56,000 KB
testcase_29 AC 172 ms
55,812 KB
testcase_30 AC 137 ms
55,980 KB
testcase_31 AC 184 ms
56,032 KB
testcase_32 AC 142 ms
56,204 KB
testcase_33 AC 177 ms
55,804 KB
testcase_34 AC 137 ms
55,944 KB
testcase_35 AC 186 ms
55,860 KB
testcase_36 AC 172 ms
55,764 KB
testcase_37 AC 142 ms
55,796 KB
testcase_38 AC 150 ms
56,120 KB
testcase_39 AC 159 ms
55,856 KB
testcase_40 AC 193 ms
56,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main{

	static final Scanner s=new Scanner(System.in);

	public static void main(String args[]){
		input();
		solve();
	}

	private static void input(){
	}
	private static void solve(){
		int n=s.nextInt(),in[]=new int[n];
		for(int i=0;i<n;i++)
			in[i]=s.nextInt();
		Arrays.sort(in);

		System.out.println(getMedian(in));
	}
	public static double getMedian(int[]/*SORTED ARRAY*/ in) {
		if(in.length%2==0) {
			return ((double)in[in.length/2-1]+in[in.length/2])/2;
		}else {
			return in[in.length/2];
		}
	}
}
0