結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2024-03-07 01:55:16 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 350 bytes |
コンパイル時間 | 2,205 ms |
コンパイル使用メモリ | 197,992 KB |
最終ジャッジ日時 | 2025-02-20 01:30:00 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i, n) for (int i = 0; i < (int)(n); i++)int main() {int n;cin>>n;vector<double> vec(n);rep(i,n){cin>>vec.at(i);}sort(vec.begin(),vec.end());if(n%2==1){cout<<vec.at(n/2)<<endl;}else{double ans=(vec.at(n/2-1)+vec.at(n/2))/2;cout<<ans<<endl;}}