結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
iwa_choco_168
|
| 提出日時 | 2019-12-22 17:59:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 388 bytes |
| コンパイル時間 | 1,858 ms |
| コンパイル使用メモリ | 171,384 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-14 13:25:25 |
| 合計ジャッジ時間 | 3,074 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main() {
int n;
cin >> n;
vector<int> num(n);
rep(i, n) cin >> num.at(i);
sort(num.begin(), num.end());
double ans;
if(n % 2 == 0) ans = (num.at(n / 2 - 1) + num.at(n / 2)) / 2.0;
else ans = num.at(n / 2);
cout << fixed << setprecision(1) << ans << endl;
}
iwa_choco_168