結果

問題 No.275 中央値を求めよ
ユーザー Ryota EnokidoRyota Enokido
提出日時 2018-12-10 12:07:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 195 ms / 1,000 ms
コード長 839 bytes
コンパイル時間 3,501 ms
コンパイル使用メモリ 71,132 KB
実行使用メモリ 58,160 KB
最終ジャッジ日時 2023-10-14 22:07:55
合計ジャッジ時間 11,394 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,812 KB
testcase_01 AC 118 ms
55,512 KB
testcase_02 AC 132 ms
56,048 KB
testcase_03 AC 118 ms
55,740 KB
testcase_04 AC 117 ms
55,952 KB
testcase_05 AC 118 ms
55,816 KB
testcase_06 AC 128 ms
55,664 KB
testcase_07 AC 184 ms
56,812 KB
testcase_08 AC 137 ms
56,028 KB
testcase_09 AC 137 ms
56,104 KB
testcase_10 AC 138 ms
55,796 KB
testcase_11 AC 120 ms
55,696 KB
testcase_12 AC 121 ms
56,176 KB
testcase_13 AC 119 ms
55,492 KB
testcase_14 AC 118 ms
55,508 KB
testcase_15 AC 194 ms
56,788 KB
testcase_16 AC 190 ms
57,208 KB
testcase_17 AC 191 ms
56,708 KB
testcase_18 AC 148 ms
55,936 KB
testcase_19 AC 182 ms
56,352 KB
testcase_20 AC 184 ms
56,440 KB
testcase_21 AC 161 ms
55,936 KB
testcase_22 AC 190 ms
56,104 KB
testcase_23 AC 165 ms
56,072 KB
testcase_24 AC 143 ms
58,152 KB
testcase_25 AC 195 ms
56,872 KB
testcase_26 AC 192 ms
56,448 KB
testcase_27 AC 187 ms
56,260 KB
testcase_28 AC 128 ms
55,768 KB
testcase_29 AC 164 ms
58,160 KB
testcase_30 AC 127 ms
55,752 KB
testcase_31 AC 185 ms
56,360 KB
testcase_32 AC 134 ms
55,780 KB
testcase_33 AC 192 ms
56,260 KB
testcase_34 AC 130 ms
55,672 KB
testcase_35 AC 183 ms
56,464 KB
testcase_36 AC 174 ms
56,048 KB
testcase_37 AC 135 ms
55,956 KB
testcase_38 AC 143 ms
55,716 KB
testcase_39 AC 142 ms
55,908 KB
testcase_40 AC 189 ms
56,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.lang.Math;

 public class Main {
     public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);

         int N = sc.nextInt();
         int[] A = new int[N];
         for(int i=0; i<N; i++){
             A[i] = sc.nextInt();
         }
         
         for(int j=0; j<A.length-1; j++){
             for(int k=N-1; k>j; k--){
                 if(A[k] < A[k-1]){
                     int temp = A[k];
                     A[k] = A[k-1];
                     A[k-1] = temp;
                 }
             }
         }
         

         if(N%2==0){
             double center = (double)(A[N/2] + A[(N/2)-1]) / 2;
             System.out.println(center);
         }else{
             int center = A[N/2];
             System.out.println(center);
         }
   
     }
 }
0