0
点赞
收藏
分享

微信扫一扫

【codevs1052】地鼠游戏

小安子啊 2023-02-08 阅读 60


problem

solution

codes

//优先打价值最大的(如果能打的化)
#include<iostream>
#include<algorithm>
using namespace std;
struct d{ int t, w; }a[110];
bool cmp(d a, d b){ return a.w>=b.w; }
int n, book[110], ans;
int main(){
cin>>n;
for(int i = 0; i < n; i++)cin>>a[i].t;
for(int i = 0; i < n; i++)cin>>a[i].w;
sort(a, a+n, cmp);
for(int i = 0; i < n; i++)
for(int j = a[i].t; j >= 1; j--)
if(!book[j]){ ans += a[i].w; book[j] = 1; break; }
cout<<ans;
return 0;
}


举报

相关推荐

0 条评论