結果
| 問題 |
No.275 中央値を求めよ
|
| ユーザー |
|
| 提出日時 | 2025-08-04 17:04:03 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 1,000 ms |
| コード長 | 862 bytes |
| コンパイル時間 | 1,155 ms |
| コンパイル使用メモリ | 103,680 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-08-04 17:04:06 |
| 合計ジャッジ時間 | 2,762 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
using namespace std;
using ll = long long;
int main(void)
{
int N;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; i++)
{
cin >> A.at(i);
}
for (int i = 1; i < N; i++)
{
int temp_itr = i - 1;
int T = A.at(i);
while (0 <= temp_itr && T <= A.at(temp_itr))
{
A.at(temp_itr + 1) = A.at(temp_itr);
A.at(temp_itr) = T;
temp_itr--;
}
}
if (A.size() % 2 == 1)
{
cout << A.at(N / 2) << endl;
}
else
{
int H = N / 2;
double R = (A.at(H) + A.at(H - 1));
cout << R / 2 << endl;
/*
if (R % 2 == 0)
{
cout << R / 2 << endl;
}
else
{
cout << R / 2 << ".5" << endl;
}
*/
}
return 0;
}