codeve1052

来源:互联网 发布:怎样在淘宝上买宠物狗 编辑:程序博客网 时间:2024/05/05 21:48

标题给的是 堆


可是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;}


0 0
原创粉丝点击