結果

問題 No.275 中央値を求めよ
ユーザー umaumax
提出日時 2017-05-02 02:35:05
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 335 bytes
コンパイル時間 597 ms
コンパイル使用メモリ 60,592 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 00:28:42
合計ジャッジ時間 1,742 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>

using namespace std;

int main(int argc, const char *argv[])
{
	int N;
	cin >> N;
	int As[N];
	for (auto &&a : As) cin >> a;
	sort(As, &As[N]);
	double ret;
	if (N % 2 == 0) {
		ret = ((double)As[N / 2 - 1] + As[N / 2]) / 2;
	}
	else {
		ret = As[N / 2];
	}
	cout << ret << endl;
	return 0;
}
0