UVA 11292-Dragon of Loowater (贪心)】的更多相关文章

贪心策略:一个直径为X的头颅,应该让雇佣费用满足大于等于X且最小的骑士来砍掉,这样才能使得花费最少. AC代码 #include <cstdio> #include <cmath> #include <algorithm> #include <cstring> #include <utility> #include <string> #include <iostream> #include <map> #inc…
Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shores of Rellau Creek in central Loowater had always been a prime breeding ground for geese. Due to the lack of predato…
Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shores of Rellau Creek in central Loowater had always been a prime breeding ground for geese. Due to the lack of predato…
Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shores of Rellau Creek in central Loowater had always been a prime breeding ground for geese. Due to the lack of predators, the geese population was out o…
Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem.The shores of Rellau Creek in central Loowater had always been a prime breeding ground for geese.Due to the lack of predators,the geese population was out of c…
简单贪心 龙头的直径和人的佣金排序,价值小的人和直径小的配 #include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> typedef long long ll; #define N 20005 using namespace std; int a[N],b[N]; int main(){ int m,n; int i,j; w…
题意:有n个条龙,在雇佣勇士去杀,每个勇士能力值为x,只能杀死头的直径y小于或等于自己能力值的龙,只能被雇佣一次,并且你要给x赏金,求最少的赏金. 析:很简单么,很明显,能力值高的杀直径大的,低的杀直径小的.所以我们先对勇士能力值从小到大排序,然后对龙的直径从小到大排序, 然后扫一遍即可,如某个勇士杀不龙,就可以跳过,扫到最后,如果杀完了就结束,输出费用,否则就是杀不完. 代码如下: #include <iostream> #include <cstdio> #include &l…
Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shores of Rellau Creek in central Loowater had always been a prime breeding ground for geese. Due to the lack of predato…
题目大意:   你的王国里有一条n个头的恶龙,你希望雇一些骑士把它杀死(即砍掉所有头).村里有m个骑士可以雇佣,一个能力值为x的骑士可以砍掉恶龙一个直径不超过x的头,且需要支付x个金币.如何雇佣骑士才能砍掉恶龙的所有头,且需要支付的金币最少?注意,一个骑士只能砍一个头(且不能被雇佣两次).  输入格式 输入包含多组数据.每组数据的第一行为正整数n和m(1≤n,m≤20 000):以下n行每行为一个整数,即恶龙每个头的直径:以下m行每行为一个整数,即每个骑士的能力.输入结束标志为n=m=0. 输出…
题目传送门 /* 题意:n个头,m个士兵,问能否砍掉n个头 贪心/思维题:两个数组升序排序,用最弱的士兵砍掉当前的头 */ #include <cstdio> #include <cstring> #include <algorithm> using namespace std; ; const int INF = 0x3f3f3f3f; int a[MAXN], b[MAXN]; int main(void) //UVA 11292 The Dragon of Loo…