Files
python/TangDou/CSP-J/AcWingTraining/T5/464_2.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

42 lines
1.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
struct Node {
int s, b;
bool operator<(const Node &W) const {
return b > W.b; // 按疲劳值降序
}
} a[N];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i].s;
for (int i = 1; i <= n; i++) cin >> a[i].b;
sort(a + 1, a + 1 + n);
for (int x = 1; x <= n; x++) {
int max_fatigue = 0;
int max_dist = 0;
int total_b = 0;
// 情况1:选择前x-1个疲劳值最大的,加上第x个的距离*2+疲劳值
for (int i = 1; i <= x; i++) {
if (i < x) {
total_b += a[i].b;
if (2 * a[i].s > max_dist) {
max_dist = 2 * a[i].s;
}
}
int current = total_b + max(2 * a[i].s + a[i].b, max_dist);
if (current > max_fatigue) {
max_fatigue = current;
}
}
cout << max_fatigue << endl;
}
return 0;
}