結果

問題 No.275 中央値を求めよ
ユーザー daradara_sanma
提出日時 2017-07-11 14:52:21
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 338 bytes
コンパイル時間 564 ms
コンパイル使用メモリ 59,228 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-07 14:57:33
合計ジャッジ時間 1,960 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
	int n;
	cin >> n;

	float A[1000],s = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
		s += A[i];
	}
	sort(A, A + n);

	if (n % 2 == 0)
	{
		cout << (A[n / 2 - 1] + A[n / 2]) / 2.0 << endl;
	}
	else
	{
		cout << s / n << endl;
	}

	return 0;
}
0