結果

問題 No.275 中央値を求めよ
ユーザー KinoshitaKinoshita
提出日時 2015-09-05 14:00:14
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 546 bytes
コンパイル時間 2,068 ms
コンパイル使用メモリ 73,952 KB
実行使用メモリ 59,596 KB
最終ジャッジ日時 2023-09-26 08:47:06
合計ジャッジ時間 10,327 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,160 KB
testcase_01 AC 122 ms
56,188 KB
testcase_02 AC 137 ms
56,140 KB
testcase_03 AC 122 ms
57,728 KB
testcase_04 AC 121 ms
55,816 KB
testcase_05 AC 121 ms
55,492 KB
testcase_06 AC 131 ms
55,776 KB
testcase_07 AC 175 ms
55,940 KB
testcase_08 WA -
testcase_09 AC 139 ms
56,340 KB
testcase_10 AC 139 ms
56,104 KB
testcase_11 WA -
testcase_12 AC 120 ms
55,644 KB
testcase_13 AC 121 ms
55,752 KB
testcase_14 AC 120 ms
56,184 KB
testcase_15 AC 183 ms
56,512 KB
testcase_16 AC 175 ms
56,228 KB
testcase_17 AC 185 ms
56,096 KB
testcase_18 AC 151 ms
56,044 KB
testcase_19 WA -
testcase_20 AC 170 ms
56,008 KB
testcase_21 AC 173 ms
56,192 KB
testcase_22 AC 177 ms
56,056 KB
testcase_23 WA -
testcase_24 AC 148 ms
56,372 KB
testcase_25 AC 182 ms
56,004 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 176 ms
56,372 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 174 ms
56,264 KB
testcase_37 AC 139 ms
56,040 KB
testcase_38 AC 151 ms
56,096 KB
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	
	static Main byakko = new Main();
	static Scanner sc = new Scanner(System.in);
	static double[] x;
	
	public static void main(String[] args)throws IOException{
		
		int n = sc.nextInt();
		x = new double[n];
		
		for(int i = 0; i < n; i++){
			x[i] = sc.nextInt();
		}
		Arrays.sort(x);
		if(n % 2 == 0){
			System.out.println((x[n / 2 - 1] + x[n / 2]) / 2);
		}else if(n % 3 == 0){
			System.out.println((int)(x[n / 2]));
		}
		sc.close();
	}
}
0