結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2016-10-09 14:14:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 1,134 bytes |
コンパイル時間 | 1,664 ms |
コンパイル使用メモリ | 172,984 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 00:04:16 |
合計ジャッジ時間 | 2,861 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <bits/stdc++.h>using namespace std;// #define int long longusing ll=long long;using vi=vector<int>;using vl=vector<long long>;using pii=pair<int,int>;#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)#define FORE(x,arr) for(auto &x:arr)#define REP(v,n) FOR(v,0,n)#define RREP(v,n) for(int v=((int)(n)-1);v>=0;v--)#define ALL(c) begin(c),end(c)#define RALL(c) rbegin(c),rend(c)#define SZ(c) ((int)c.size())#define DUMP(x) cerr<<#x<<":="<<(x)<<endlconst int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};const int INF=1e9; const long long INFLL=1e18;template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){os<<"("<<p.first<<" "<<p.second<<")";return os;}template<class T>ostream&operator<<(ostream &os,const vector<T> &v){ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}//------------------------------------------------------------------------------signed main() {int n;cin>>n;vi a(n);REP(i,n) cin>>a[i];sort(ALL(a));cout<<(n%2==1?a[n/2]:(a[n/2-1]+a[n/2])/2.0)<<endl;return 0;}