結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2017-12-19 22:41:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 364 bytes |
コンパイル時間 | 688 ms |
コンパイル使用メモリ | 65,132 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-25 00:48:00 |
合計ジャッジ時間 | 1,566 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n=0; cin>>n; vector<double> p; double tmp=0; for(int i=0; i<n; i++){ cin>>tmp; p.push_back(tmp); } sort(p.begin(),p.end()); int s = n/2; int a = n%2; if(a == 0){ cout<<(p[s-1]+p[s])/2<<endl; }else { cout<<p[s+a-1]<<endl; } return 0; }