結果

問題 No.275 中央値を求めよ
ユーザー Rp7rf
提出日時 2015-09-04 22:33:40
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 276 bytes
コンパイル時間 478 ms
コンパイル使用メモリ 58,840 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 00:56:57
合計ジャッジ時間 1,586 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 3 WA * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;

int main(void){
  int n;
  cin>>n;
  vector<int> in(n);
  for(int i=0;i<n;i++){
    cin>>in[i];
  }
  if(n%2){
    //odd
    cout<<in[n/2+1]<<endl;
  }else{
    //even
    cout<<1.0*(in[n/2]+in[n/2+1])/2<<endl;
  }

}
0