結果

問題 No.275 中央値を求めよ
ユーザー syoken_desuka
提出日時 2015-09-04 22:45:11
言語 C++11
(gcc 4.8.5)
結果
AC  
実行時間 4 ms
コード長 2,139 Byte
コンパイル時間 1,258 ms
使用メモリ 8,916 KB
最終ジャッジ日時 2018-11-28 01:24:39

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
99_system_test1.txt AC 4 ms
6,868 KB
99_system_test2.txt AC 3 ms
6,872 KB
99_system_test3.txt AC 2 ms
6,868 KB
sample1.txt AC 3 ms
6,872 KB
sample2.txt AC 3 ms
6,872 KB
sample3.txt AC 3 ms
8,912 KB
system_test1.txt AC 4 ms
6,868 KB
system_test2.txt AC 3 ms
6,872 KB
system_test3.txt AC 3 ms
8,912 KB
system_test4.txt AC 4 ms
6,872 KB
system_test5.txt AC 3 ms
6,872 KB
test1.txt AC 4 ms
6,872 KB
test2.txt AC 3 ms
8,916 KB
test3.txt AC 3 ms
6,872 KB
test4.txt AC 4 ms
6,872 KB
test5.txt AC 4 ms
6,868 KB
test6.txt AC 3 ms
6,868 KB
test7.txt AC 4 ms
6,868 KB
test8.txt AC 2 ms
6,872 KB
test9.txt AC 3 ms
8,916 KB
test10.txt AC 3 ms
6,872 KB
test11.txt AC 3 ms
6,872 KB
test12.txt AC 3 ms
6,868 KB
test13.txt AC 3 ms
6,868 KB
test14.txt AC 2 ms
6,872 KB
test15.txt AC 3 ms
8,916 KB
test16.txt AC 3 ms
6,868 KB
test17.txt AC 4 ms
6,872 KB
test18.txt AC 3 ms
8,916 KB
test19.txt AC 3 ms
6,872 KB
test20.txt AC 2 ms
6,872 KB
test21.txt AC 4 ms
6,872 KB
test22.txt AC 3 ms
6,872 KB
test23.txt AC 3 ms
6,868 KB
test24.txt AC 3 ms
6,868 KB
test25.txt AC 2 ms
6,872 KB
test26.txt AC 3 ms
8,916 KB
test27.txt AC 3 ms
6,868 KB
test28.txt AC 4 ms
6,872 KB
test29.txt AC 3 ms
6,868 KB
test30.txt AC 4 ms
6,872 KB
テストケース一括ダウンロード
コンパイルメッセージ
main.cpp:27:15: warning: ISO C99 requires whitespace after the macro name [enabled by default]
 #define DEBUG1{}
               ^
main.cpp:27:0: warning: "DEBUG1" redefined [enabled by default]
 #define DEBUG1{}
 ^
main.cpp:22:0: note: this is the location of the previous definition
 #define DEBUG1(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
 ^
main.cpp:28:15: warning: ISO C99 requires whitespace after the macro name [enabled by default]
 #define DEBUG2{}
               ^
main.cpp:28:0: warning: "DEBUG2" redefined [enabled by default]
 #define DEBUG2{}
 ^
main.cpp:23:0: note: this is the location of the previous definition
 #define DEBUG2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; DEBUG1(var1); }
 ^
main.cpp:29:15: warning: ISO C99 requires whitespace after the macro name [enabled by default]
 #define DEBUG3{}
               ^
main.cpp:29:0: warning: "DEBUG3" redefined [enabled by default]
 #define DEBUG3{}
 ^
main.cpp:24:0: note: this is the location of the previous definition
 #define DEBUG3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; DEBUG2(var1, var2); }
 ^
main.cpp:30:15: warning: ISO C99 requires whitespace after the macro name [enabled by default]
 #define DEBUG4{}
               ^
main.cpp:30:0: warning: "DEBUG4" redefined [enabled by default]
 #define DEBUG4{}
 ^
main.cpp:25:0: note: this is the location of the previous definition
 #define DEBUG4(var0, var1, var2, var3) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; DEBUG3(var1, var2, var3); }
 ^

ソースコード

diff #
#include "bits/stdc++.h"
using namespace std;
//諸機能
#pragma region MACRO
#define ANSWER(x) cerr << "answer: "; cout << (x) << endl
#define DOUBLE_ANSWER(x) cerr << "answer: "; cout << setprecision(10) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define ALL(a) begin((a)),end((a))
#define FILL(a,n) for(auto &hoge : (a)) hoge = (n)
#define mp make_pair
#define EXIST(container, n) ((container).find((n)) != (container).end())
#define STOI(s,i,l) stoi(SUBSTR(s,i,l))
#define SUBSTR(s,i,l) string((s), (i), (l))
#define NPI_TO_RAD(x) (180.0*x/PI)
#define RAD_TO_NPI(x) (PI/180.0*x)
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#define DEBUG1(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define DEBUG2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; DEBUG2(var1, var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; DEBUG3(var1, var2, var3); }
#ifndef _DEBUG //デバッグでないなら、計算時間短縮のためにエラー出力を無効化
#define DEBUG1{}
#define DEBUG2{}
#define DEBUG3{}
#define DEBUG4{}
#endif
//typedef(書き換える、書き足す可能性ある)
#pragma region TYPE_DEF
typedef long long ll; 
typedef pair<int,int> pii;
typedef pair<string,string> pss;
typedef pair<int,string>pis;
typedef pair<string,int>psi;
typedef vector<string> vs;
typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9 + 7)
#pragma endregion

int main()
{
	int n;
	vector<double> a;
	cin >> n;
	rep(i, n)
	{
		int p;
		cin >> p;
		a.push_back(p);
	}
	sort(ALL(a));
	double answer = 0;
	if (a.size() % 2 == 0)
	{
		DOUBLE_ANSWER(( a[a.size() / 2 - 1] + a[a.size() / 2] ) / 2);
	}
	else
	{
		DOUBLE_ANSWER(a[a.size() / 2]);
	}

	return 0;
}
0