From 4afeb0c291ba05820f451c66ea1db2e70bdd4698 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Thu, 18 Jul 2024 09:24:35 +0800 Subject: [PATCH] =?UTF-8?q?P3887=20[GDOI2014]=20=E4=B8=96=E7=95=8C?= =?UTF-8?q?=E6=9D=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.luogu.com.cn/record/166789276 --- Luogu/P3887/P3887.cpp | 69 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Luogu/P3887/P3887.cpp diff --git a/Luogu/P3887/P3887.cpp b/Luogu/P3887/P3887.cpp new file mode 100644 index 00000000..97f2ce75 --- /dev/null +++ b/Luogu/P3887/P3887.cpp @@ -0,0 +1,69 @@ +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +int k, d, m, f, q; +std::priority_queue q_k, q_d, q_m, q_f; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> k >> d >> m >> f; + + for (int i = 1, x; i <= k; i++) { + cin >> x; + q_k.emplace(x); // 入堆 + } + + for (int i = 1, x; i <= d; i++) { + cin >> x; + q_d.emplace(x); + } + + for (int i = 1, x; i <= m; i++) { + cin >> x; + q_m.emplace(x); + } + + for (int i = 1, x; i <= f; i++) { + cin >> x; + q_f.emplace(x); + } + + cin >> q; + + while (q--) { + int a, b, c; + + cin >> a >> b >> c; + + int sum = 0; + + sum += q_k.top(); // 取堆顶元素(最大值) + q_k.pop(); + + for (int i = 1; i <= a; i++) { + sum += q_d.top(); + q_d.pop(); + } + + for (int i = 1; i <= b; i++) { + sum += q_m.top(); + q_m.pop(); + } + + for (int i = 1; i <= c; i++) { + sum += q_f.top(); + q_f.pop(); + } + + cout << std::fixed << std::setprecision(2) << static_cast(sum) / (a + b + c + 1) << endl; + } + + return 0; +}