You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
757 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
const int N = 510;
int n;
int t[N], r[N];
int a[N], al;
/*
7
4 2 4 3 1 4 6
70 60 50 40 30 20 10
230
*/
int ans;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> t[i];
for (int i = 1; i <= n; i++) cin >> r[i];
// 假设最终选择了k个
for (int k = 1; k <= n; k++) {
al = 0;
// 将符合k个限制的所有游戏找出来
for (int i = 1; i <= n; i++)
if (t[i] >= k) a[al++] = r[i];
sort(a, a + al);
int sum = 0;
for (int i = al; i >= max(al - k, 0); i--) sum += a[i];
ans = max(ans, sum);
}
cout << ans << endl;
return 0;
}