結果

問題 No.275 中央値を求めよ
ユーザー 4802525
提出日時 2019-03-20 02:08:23
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 474 bytes
コンパイル時間 1,493 ms
コンパイル使用メモリ 162,012 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-14 20:20:13
合計ジャッジ時間 2,783 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
  int first;
  int second;
  int third;
}T;

//昇順
bool comp_Se(T& l, T& r){
  return l.second < r.second;
}

int main(void){
  int N;
  cin >> N;
  int i;
  vector<int> A(N);
  REP(i,N) cin >> A[i];
  sort(A.begin(),A.end());
  if(N%2) cout << A[N/2] << endl;
  else cout << (float)(A[N/2] + A[N/2-1])/2 << endl;
  return 0;
}
0