結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-05-22 16:39:41 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 416 bytes |
| コンパイル時間 | 726 ms |
| コンパイル使用メモリ | 69,540 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-24 23:50:03 |
| 合計ジャッジ時間 | 2,041 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
double n,a,ans;
vector<double> v;
cin>>n;
for(int i=0; i<n; ++i){
cin>>a;
v.push_back(a);
}
sort(v.begin(), v.end());
if(v.size()%2==0){
ans=(v[v.size()/2-1]+v[v.size()/2])/2;
cout<<ans<<endl;
} else {
ans=v[ceil((v.size()-1)/2)];
cout<<ans<<endl;
}
return 0;
}