結果
問題 | No.275 中央値を求めよ |
ユーザー |
|
提出日時 | 2018-05-19 15:12:17 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 972 bytes |
コンパイル時間 | 724 ms |
コンパイル使用メモリ | 90,024 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 01:27:11 |
合計ジャッジ時間 | 1,876 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <string> #include <sstream> #include <complex> #include <algorithm> #include <functional> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <cmath> #include <cassert> #include <fstream> #define REP(i,n) for(int i=0;i<n;i++) #define FOR(a,b) for(:a<b;a++) #define SSTR( x ) static_cast< std::ostringstream & >( \ ( std::ostringstream() << std::dec << x ) ).str() #define ALL(s) (s).begin(), (s).end() using namespace std; typedef long long unsigned int llu; typedef long long ll; int main (){ int n; while (cin >> n){ double ans; vector<int> a; REP(i,n){ int ma; cin >> ma; a.push_back(ma); } sort(ALL(a)); int size = n; if(n%2 == 0){ ans = (double)(a[n/2-1] + a[n/2])/(double)2; }else{ ans = a[n/2]; } cout << ans << endl; a.clear(); } return 0; }