結果

問題 No.275 中央値を求めよ
ユーザー fal_rnd
提出日時 2017-03-31 16:19:21
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 532 bytes
コンパイル時間 1,627 ms
コンパイル使用メモリ 74,200 KB
実行使用メモリ 54,840 KB
最終ジャッジ日時 2024-07-07 04:43:46
合計ジャッジ時間 8,388 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 6 WA * 31 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main{

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

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

	private static void input(){
	}

	private static void solve(){
		int[] in=new int[s.nextInt()];
		for(int i=0;i<in.length;i++)
			in[i]=s.nextInt();
		System.out.println(getMedian(in));
	}
	public static double getMedian(int[]/*SORTED ARRAY*/ in) {
		if(in.length%2==0) {
			return ((double)in[in.length/2]+in[in.length/2-1])/2;
		}else {
			return in[in.length/2+1];
		}
	}
}
0