結果

問題 No.275 中央値を求めよ
ユーザー めうめう🎒
提出日時 2016-01-17 12:39:20
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 502 bytes
コンパイル時間 831 ms
コンパイル使用メモリ 75,596 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-24 23:39:25
合計ジャッジ時間 1,970 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <math.h>
#include <stack>
#include <set>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <cstdio>
#include <vector>
using namespace std;

#define INF (1 << 30)
#define INFLL (1LL << 60)

int main() {
	int n;
	float A[1001];
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> A[i];
	}
	sort(A,A + n);
	if(n % 2 == 1){
		cout << A[n/2] << endl;
	}else{
		cout << (A[n/2-1] + A[n/2]) / 2 << endl;
	}
	return 0;
}
0