結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2016-06-05 04:51:44 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 403 bytes |
コンパイル時間 | 643 ms |
コンパイル使用メモリ | 69,156 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-24 23:51:19 |
合計ジャッジ時間 | 1,781 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <iostream>#include <stdio.h>#include <math.h>#include <vector>#include <algorithm>using namespace std;int main(){int n;cin >> n;vector<int> a;for(int i=0;i<n;i++) {int tmp;cin >> tmp;a.push_back(tmp);}sort(a.begin(),a.end());double ans=0.0;if(a.size()%2 == 0) ans = (double)(a[a.size()/2-1]+a[a.size()/2])/2;else ans = a[a.size()/2];cout << ans << endl;}