結果
| 問題 |
No.275 中央値を求めよ
|
| ユーザー |
|
| 提出日時 | 2025-08-04 16:59:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 825 bytes |
| コンパイル時間 | 1,059 ms |
| コンパイル使用メモリ | 103,796 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-08-04 16:59:54 |
| 合計ジャッジ時間 | 3,081 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 WA * 1 |
ソースコード
#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;
int R = (A.at(H) + A.at(H - 1));
if (R % 2 == 0)
{
cout << R / 2 << endl;
}
else
{
cout << R / 2 << ".5" << endl;
}
}
return 0;
}