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

B3872 [GESP202309 五级] 巧夺大奖

https://www.luogu.com.cn/record/174742232
This commit is contained in:
Baoshuo Ren 2024-08-25 23:20:42 +08:00
parent 5550877018
commit c7114f4976
Failed to extract signature

48
Luogu/B3872/B3872.cpp Normal file
View File

@ -0,0 +1,48 @@
#include <iostream>
#include <algorithm>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 505;
int n, ans;
bool t[N];
struct node {
int t, r;
} a[N];
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i].t;
}
for (int i = 1; i <= n; i++) {
cin >> a[i].r;
}
std::sort(a + 1, a + 1 + n, [&](const node &a, const node &b) {
return a.r > b.r;
});
for (int i = 1; i <= n; i++) {
for (int j = a[i].t; j; j--) {
if (!t[j]) {
t[j] = true;
ans += a[i].r;
break;
}
}
}
cout << ans << endl;
return 0;
}