0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 18:48:48 +00:00

P3887 [GDOI2014] 世界杯

https://www.luogu.com.cn/record/166789276
This commit is contained in:
Baoshuo Ren 2024-07-18 09:24:35 +08:00
parent 780296a1bf
commit 4afeb0c291
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

69
Luogu/P3887/P3887.cpp Normal file
View File

@ -0,0 +1,69 @@
#include <iostream>
#include <iomanip>
#include <queue>
using std::cin;
using std::cout;
const char endl = '\n';
int k, d, m, f, q;
std::priority_queue<int> 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<double>(sum) / (a + b + c + 1) << endl;
}
return 0;
}