From 782ac0d88216d47dc86db61a8246df6200322559 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sun, 15 Nov 2020 19:50:33 +0800 Subject: [PATCH] =?UTF-8?q?P3369=20=E3=80=90=E6=A8=A1=E6=9D=BF=E3=80=91?= =?UTF-8?q?=E6=99=AE=E9=80=9A=E5=B9=B3=E8=A1=A1=E6=A0=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R41954295 --- problem/P3369/P3369.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 problem/P3369/P3369.cpp diff --git a/problem/P3369/P3369.cpp b/problem/P3369/P3369.cpp new file mode 100644 index 00000000..5ae1247b --- /dev/null +++ b/problem/P3369/P3369.cpp @@ -0,0 +1,31 @@ +#include + +using namespace std; + +int main() { + int n, x, opt; + vector a; + cin >> n; + for (int i = 0; i < n; i++) { + cin >> opt >> x; + if (opt == 1) { + a.insert(lower_bound(a.begin(), a.end(), x), x); + } + else if (opt == 2) { + a.erase(lower_bound(a.begin(), a.end(), x)); + } + else if (opt == 3) { + cout << lower_bound(a.begin(), a.end(), x) - a.begin() + 1 << endl; + } + else if (opt == 4) { + cout << a[x - 1] << endl; + } + else if (opt == 5) { + cout << *(lower_bound(a.begin(), a.end(), x) - 1) << endl; + } + else if (opt == 6) { + cout << *upper_bound(a.begin(), a.end(), x) << endl; + } + } + return 0; +}