結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
wahr69
|
| 提出日時 | 2015-09-04 22:24:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 634 bytes |
| コンパイル時間 | 1,045 ms |
| コンパイル使用メモリ | 90,840 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-24 23:07:49 |
| 合計ジャッジ時間 | 1,928 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <iostream>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <sstream>
#include <memory>
#include <cassert>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef unsigned long long ull;
int main()
{
int N;
cin >> N;
vector<int> 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] << endl;
} else {
cout << (a[N / 2 - 1] + a[N / 2]) / 2.0 << endl;
}
}
wahr69