結果

問題 No.275 中央値を求めよ
ユーザー kenji_shioyakenji_shioya
提出日時 2016-05-24 04:54:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 193 ms / 1,000 ms
コード長 594 bytes
コンパイル時間 4,074 ms
コンパイル使用メモリ 73,136 KB
実行使用メモリ 58,096 KB
最終ジャッジ日時 2023-09-07 05:23:25
合計ジャッジ時間 11,377 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,904 KB
testcase_01 AC 125 ms
56,100 KB
testcase_02 AC 140 ms
58,096 KB
testcase_03 AC 124 ms
56,152 KB
testcase_04 AC 126 ms
56,148 KB
testcase_05 AC 124 ms
55,880 KB
testcase_06 AC 134 ms
56,240 KB
testcase_07 AC 183 ms
56,384 KB
testcase_08 AC 142 ms
56,208 KB
testcase_09 AC 144 ms
56,184 KB
testcase_10 AC 146 ms
55,576 KB
testcase_11 AC 126 ms
56,156 KB
testcase_12 AC 127 ms
55,992 KB
testcase_13 AC 125 ms
56,168 KB
testcase_14 AC 124 ms
56,300 KB
testcase_15 AC 190 ms
56,240 KB
testcase_16 AC 188 ms
56,412 KB
testcase_17 AC 188 ms
56,268 KB
testcase_18 AC 152 ms
56,256 KB
testcase_19 AC 182 ms
55,876 KB
testcase_20 AC 183 ms
56,432 KB
testcase_21 AC 177 ms
54,828 KB
testcase_22 AC 185 ms
55,820 KB
testcase_23 AC 179 ms
56,364 KB
testcase_24 AC 153 ms
56,172 KB
testcase_25 AC 191 ms
56,272 KB
testcase_26 AC 186 ms
55,892 KB
testcase_27 AC 182 ms
56,220 KB
testcase_28 AC 136 ms
56,208 KB
testcase_29 AC 164 ms
55,844 KB
testcase_30 AC 138 ms
55,852 KB
testcase_31 AC 184 ms
55,868 KB
testcase_32 AC 142 ms
55,964 KB
testcase_33 AC 186 ms
56,584 KB
testcase_34 AC 141 ms
56,112 KB
testcase_35 AC 190 ms
57,160 KB
testcase_36 AC 187 ms
56,288 KB
testcase_37 AC 148 ms
55,940 KB
testcase_38 AC 163 ms
55,796 KB
testcase_39 AC 156 ms
56,112 KB
testcase_40 AC 193 ms
56,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.Arrays;

public class Exercises8{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    int numLength = sc.nextInt();

    int[] numArray = new int[numLength];

    for (int n = 0; n < numLength; n++){
      numArray[n] = sc.nextInt();
    }
    
    Arrays.sort(numArray);

    float middle;
    if (numLength % 2 == 0){
      middle = ((float)numArray[numLength / 2] + (float)numArray[numLength / 2 - 1]) / 2;
    }else{
      middle = (float)numArray[numLength / 2];
    }

    System.out.println(middle);
  }
}
0