結果

問題 No.275 中央値を求めよ
ユーザー Mcpu3Mcpu3
提出日時 2018-06-22 00:47:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 203 ms / 1,000 ms
コード長 457 bytes
コンパイル時間 2,024 ms
コンパイル使用メモリ 71,652 KB
実行使用メモリ 57,540 KB
最終ジャッジ日時 2023-09-07 07:28:23
合計ジャッジ時間 10,272 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,832 KB
testcase_01 AC 127 ms
56,184 KB
testcase_02 AC 141 ms
55,972 KB
testcase_03 AC 124 ms
55,908 KB
testcase_04 AC 128 ms
55,724 KB
testcase_05 AC 125 ms
55,772 KB
testcase_06 AC 137 ms
55,896 KB
testcase_07 AC 192 ms
55,948 KB
testcase_08 AC 145 ms
55,688 KB
testcase_09 AC 145 ms
55,948 KB
testcase_10 AC 147 ms
55,992 KB
testcase_11 AC 127 ms
55,948 KB
testcase_12 AC 124 ms
55,800 KB
testcase_13 AC 125 ms
55,664 KB
testcase_14 AC 125 ms
55,732 KB
testcase_15 AC 201 ms
56,956 KB
testcase_16 AC 203 ms
56,160 KB
testcase_17 AC 200 ms
57,000 KB
testcase_18 AC 159 ms
55,896 KB
testcase_19 AC 195 ms
56,420 KB
testcase_20 AC 194 ms
56,844 KB
testcase_21 AC 166 ms
56,032 KB
testcase_22 AC 202 ms
56,644 KB
testcase_23 AC 167 ms
56,172 KB
testcase_24 AC 152 ms
55,712 KB
testcase_25 AC 201 ms
56,872 KB
testcase_26 AC 202 ms
56,320 KB
testcase_27 AC 199 ms
56,644 KB
testcase_28 AC 130 ms
55,932 KB
testcase_29 AC 162 ms
55,968 KB
testcase_30 AC 137 ms
55,516 KB
testcase_31 AC 198 ms
56,612 KB
testcase_32 AC 142 ms
55,776 KB
testcase_33 AC 195 ms
57,364 KB
testcase_34 AC 135 ms
56,096 KB
testcase_35 AC 195 ms
57,540 KB
testcase_36 AC 179 ms
56,428 KB
testcase_37 AC 143 ms
55,948 KB
testcase_38 AC 146 ms
55,880 KB
testcase_39 AC 152 ms
55,720 KB
testcase_40 AC 199 ms
56,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class no275{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n,i,j,t,a[]=new int[1000];
		n=stdIn.nextInt();
		for(i=0;i<n;i++) a[i]=stdIn.nextInt();
		for(i=0;i<n-1;i++) {
			for(j=n-1;j>i;j--) {
				if(a[j-1]>a[j]) {
					t=a[j-1];
					a[j-1]=a[j];
					a[j]=t;
				}
			}
		}
		if(n%2==0) System.out.print((a[n/2-1]+a[n/2])/2.);
		else System.out.print(a[n/2]);
	}
}
0