42 lines
1.0 KiB
C++
42 lines
1.0 KiB
C++
#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;
|
||
} |