标题给的是 堆
可是n == 100 是要闹哪样
我才没时间写dp+堆结构的。。
果断乱搞水过
#include <iostream>
#include <algorithm>
using namespace std;
struct MES {
int w,t;
bool operator < (const MES &b)const {
return w > b.w;
}
}m[101];
int n,a,res[101];
int F (int i) {
if(res[m[i].t]) {
for(int j = m[i].t;j >= 1;j--)
if(!res[j])
return res[j] = 1,m[i].w;
}
else return res[m[i].t] = 1,m[i].w;
return 0;
}
int main () {
cin >> n;
for(int i = 1;i <= n;i++)
cin >> m[i].t;
for(int i = 1;i <= n;i++)
cin >> m[i].w;
sort(m + 1,m + 1 + n);
for(int i = 1;i <= n;i++)
a += F(i);
cout << a << endl;
}