結果

問題 No.275 中央値を求めよ
ユーザー 29da16429da164
提出日時 2020-07-22 13:46:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 744 bytes
コンパイル時間 746 ms
コンパイル使用メモリ 65,120 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-02 11:08:01
合計ジャッジ時間 5,547 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 RE -
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,388 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 2 ms
4,380 KB
testcase_29 RE -
testcase_30 AC 1 ms
4,380 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 AC 1 ms
4,384 KB
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

void aaa(int *a,int start,int end){
  if(start<end){
	for(int i=start;i<end; i++){
      if(a[i]>a[i+1]){
        int tmp=a[i];
        a[i]=a[i+1];
        a[i+1]=tmp;
        //std::cout << "t";
      }
    }
    aaa(a,start,end-1);
  }
}

int main(void){
  
  int n;
  int x[100];
  
  for(int i=0;i<100;i++) x[i]=0;

  std::cin >> n;
  
  for(int i=0;i<n;i++){
    std::cin >> x[i];
  }
  /*
  for(int i=0;i<n;i++){
    std::cout << x[i] <<',';
  }  
  std::cout << std::endl;
  */
  aaa(x, 0, n-1);
  if(n%2==1){
    std::cout << x[n/2] <<std::endl;
  }
  else{
    std::cout << (x[n/2-1]+x[n/2])/2.0 <<std::endl;
  }

  
  /*
  for(int i=0;i<n;i++){
    std::cout << x[i] <<',';
  }  
  std::cout << std::endl;
  */
}
0