結果

問題 No.275 中央値を求めよ
ユーザー kou6839
提出日時 2015-09-06 16:54:26
言語 Java
(openjdk 23)
結果
AC  
実行時間 187 ms / 1,000 ms
コード長 539 bytes
コンパイル時間 2,699 ms
コンパイル使用メモリ 78,780 KB
実行使用メモリ 42,660 KB
最終ジャッジ日時 2024-06-24 23:14:23
合計ジャッジ時間 10,120 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.ObjectInputStream.GetField;
import java.net.NetworkInterface;
import java.util.*;
import java.util.zip.Inflater;

import javax.swing.plaf.synth.SynthSpinnerUI;


public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int[] input = new int[N];
		for(int i=0; i<N; i++) input[i]=sc.nextInt();
		Arrays.sort(input);
		
		if(N%2!=0){
			System.out.println(input[(N-1)/2]);
		}else{
			System.out.println(1.0*(input[N/2]+input[(N-1)/2])/2);
		}
	}	
}
0