結果
| 問題 |
No.275 中央値を求めよ
|
| ユーザー |
mine691
|
| 提出日時 | 2019-08-15 00:40:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 440 bytes |
| コンパイル時間 | 1,780 ms |
| コンパイル使用メモリ | 171,152 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 14:42:28 |
| 合計ジャッジ時間 | 2,928 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
int main()
{
int N;
cin >> N;
vector<double> a(N);
for (int i = 0; i < N; i++)
{
cin >> a[i];
}
sort(a.begin(), a.end());
if (N % 2 == 0)
cout << (a[N / 2] + a[(N - 1) / 2]) / 2. << endl;
else
cout << a[N / 2] << endl;
}
mine691