結果

問題 No.275 中央値を求めよ
ユーザー IL_mstaIL_msta
提出日時 2015-09-05 06:55:18
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 887 bytes
コンパイル時間 565 ms
使用メモリ 3,772 KB
最終ジャッジ日時 2023-01-22 20:01:52
合計ジャッジ時間 2,132 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
3,764 KB
testcase_01 AC 1 ms
3,580 KB
testcase_02 AC 2 ms
3,596 KB
testcase_03 AC 1 ms
3,516 KB
testcase_04 AC 1 ms
3,676 KB
testcase_05 AC 1 ms
3,624 KB
testcase_06 AC 2 ms
3,592 KB
testcase_07 AC 1 ms
3,596 KB
testcase_08 AC 1 ms
3,404 KB
testcase_09 AC 1 ms
3,400 KB
testcase_10 AC 1 ms
3,712 KB
testcase_11 AC 2 ms
3,532 KB
testcase_12 AC 1 ms
3,668 KB
testcase_13 AC 2 ms
3,392 KB
testcase_14 AC 1 ms
3,592 KB
testcase_15 AC 1 ms
3,592 KB
testcase_16 AC 1 ms
3,716 KB
testcase_17 AC 1 ms
3,628 KB
testcase_18 AC 1 ms
3,704 KB
testcase_19 AC 1 ms
3,464 KB
testcase_20 AC 1 ms
3,696 KB
testcase_21 AC 1 ms
3,680 KB
testcase_22 AC 2 ms
3,772 KB
testcase_23 AC 1 ms
3,404 KB
testcase_24 AC 2 ms
3,712 KB
testcase_25 AC 1 ms
3,728 KB
testcase_26 AC 1 ms
3,504 KB
testcase_27 AC 1 ms
3,540 KB
testcase_28 AC 1 ms
3,452 KB
testcase_29 AC 1 ms
3,408 KB
testcase_30 AC 1 ms
3,400 KB
testcase_31 AC 2 ms
3,696 KB
testcase_32 AC 2 ms
3,504 KB
testcase_33 AC 1 ms
3,520 KB
testcase_34 AC 1 ms
3,480 KB
testcase_35 AC 1 ms
3,508 KB
testcase_36 AC 1 ms
3,500 KB
testcase_37 AC 2 ms
3,716 KB
testcase_38 AC 1 ms
3,732 KB
testcase_39 AC 2 ms
3,504 KB
testcase_40 AC 2 ms
3,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
#include <sstream>
 
#include <algorithm>
#include <cmath>
 
#include <string>
//#include <array>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
 
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(16);//
	
	int N;
	cin >> N;
	vector<int> v(N);
	rep(i,N){
		cin >> v[i];
	}
	sort( v.begin(), v.end() );

	if( N%2 ){//in N==1
		P( v[N/2] );
		return 0;
	}

	double L,R,ans;
	L = v[N/2-1];
	R = v[N/2];
	ans = (L+R)/2;
	P( ans );
	return 0;
}
0