勇者斗恶龙

来源:互联网 发布:电脑多媒体播放软件 编辑:程序博客网 时间:2024/04/30 04:11

勇者斗恶龙
你的王国里有一条n个头的恶龙,你希望雇一些骑士把他杀死(即砍掉所有头)。村里有m个骑士可以雇佣,一个能力值为x的骑士可以砍掉恶龙一个直径不超过x的头,且需要支付x个金币。如何雇佣骑士才能砍掉恶龙的所有头,且需要支付的金币最少?

include

include

using namespace std;
const int maxn =20000+5;
int A[maxn],B[maxn];
int main(){
int n,m;
while (scanf(“%d%d”,&n,&m) ==2 &&n &&m){
for(int i=0;i

0 0