From 86a61ddaf69829cb22028efed56e6e26e389ab2a Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Mon, 16 Nov 2020 18:42:08 +0800 Subject: [PATCH] =?UTF-8?q?P3871=20[TJOI2010]=E4=B8=AD=E4=BD=8D=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R42008699 --- problem/P3871/P3871.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 problem/P3871/P3871.cpp diff --git a/problem/P3871/P3871.cpp b/problem/P3871/P3871.cpp new file mode 100644 index 00000000..bc24c7e9 --- /dev/null +++ b/problem/P3871/P3871.cpp @@ -0,0 +1,26 @@ +#include + +using namespace std; + +int main() { + int n,m, t; + string op; + vector nums; + cin >> n; + for(int i = 0 ; i < n ; i++) { + cin >> t; + nums.insert(lower_bound(nums.begin(), nums.end(), t), t); + } + cin >> m; + for(int i = 0 ; i < m ; i++) { + cin >> op; + if(op == "add") { + cin >> t; + nums.insert(lower_bound(nums.begin(), nums.end(), t), t); + } + else { + cout << nums[nums.size() / 2 - (nums.size() & 1 ^ 1)] << endl; + } + } + return 0; +}