結果

問題 No.275 中央値を求めよ
ユーザー jimanojimano
提出日時 2016-01-11 11:55:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 56 ms / 1,000 ms
コード長 841 bytes
コンパイル時間 3,791 ms
コンパイル使用メモリ 72,888 KB
実行使用メモリ 51,484 KB
最終ジャッジ日時 2023-09-07 05:09:11
合計ジャッジ時間 7,231 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,448 KB
testcase_01 AC 44 ms
49,364 KB
testcase_02 AC 47 ms
49,316 KB
testcase_03 AC 45 ms
49,500 KB
testcase_04 AC 44 ms
49,472 KB
testcase_05 AC 44 ms
47,408 KB
testcase_06 AC 46 ms
49,316 KB
testcase_07 AC 50 ms
49,296 KB
testcase_08 AC 48 ms
47,600 KB
testcase_09 AC 49 ms
47,832 KB
testcase_10 AC 47 ms
49,612 KB
testcase_11 AC 45 ms
49,348 KB
testcase_12 AC 45 ms
49,272 KB
testcase_13 AC 46 ms
49,584 KB
testcase_14 AC 45 ms
49,452 KB
testcase_15 AC 54 ms
49,668 KB
testcase_16 AC 55 ms
49,852 KB
testcase_17 AC 54 ms
49,460 KB
testcase_18 AC 47 ms
49,536 KB
testcase_19 AC 51 ms
49,500 KB
testcase_20 AC 52 ms
49,336 KB
testcase_21 AC 48 ms
49,412 KB
testcase_22 AC 54 ms
49,628 KB
testcase_23 AC 51 ms
49,336 KB
testcase_24 AC 48 ms
49,368 KB
testcase_25 AC 56 ms
49,892 KB
testcase_26 AC 53 ms
49,488 KB
testcase_27 AC 56 ms
49,356 KB
testcase_28 AC 47 ms
51,484 KB
testcase_29 AC 49 ms
49,340 KB
testcase_30 AC 47 ms
49,352 KB
testcase_31 AC 53 ms
49,476 KB
testcase_32 AC 48 ms
49,352 KB
testcase_33 AC 52 ms
49,476 KB
testcase_34 AC 47 ms
49,520 KB
testcase_35 AC 51 ms
47,736 KB
testcase_36 AC 51 ms
49,272 KB
testcase_37 AC 47 ms
49,280 KB
testcase_38 AC 48 ms
49,828 KB
testcase_39 AC 48 ms
49,316 KB
testcase_40 AC 53 ms
49,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class No0275 {
	public static void main(String[] args) {
		try (BufferedReader br = 
				new BufferedReader(new InputStreamReader(System.in))) {
	        int N = Integer.parseInt(br.readLine());
	        String[] str = br.readLine().split(" ");
	        int[] A = new int[N];
	        int length = A.length;
	        int l = length / 2;
	        
	        for (int i = 0; i < N ; i++) {
	        	A[i] = Integer.parseInt(str[i]);
	        }
	        Arrays.sort(A);	        
	        
	        if(length % 2 == 0){
	        	System.out.println( (double)(A[l - 1] + A[l]) / 2);
	        } else {
	        	System.out.println(A[l]);
	        }
	        
		} catch (IOException e) {
			e.printStackTrace();
		}
    }
}
0