結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-07-25 12:07:56 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 469 bytes |
| コンパイル時間 | 830 ms |
| コンパイル使用メモリ | 82,248 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-24 23:58:20 |
| 合計ジャッジ時間 | 1,762 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
int main(){
int n;
cin>>n;
int g[1004]={};
for(int i=0;i<n;i++)
cin>>g[i];
sort(g,g+n);
double ans;
if(n%2){
cout<<g[n/2]<<endl;
}
else{ans=((double)g[n/2]+(double)g[n/2-1])/2;
cout<<ans<<endl;
}
return 0;
}