UVa11292】的更多相关文章

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2267 有一条n个头的恶龙,现在有m个骑士可以雇佣去杀死他,一个能力值为x的勇士可以砍掉直径不超过x的头,而且需要支付x个金币.如何雇佣才能砍掉所有的头且支付最少的金币,注意一个勇士只能砍一个头,也只能被雇佣一次. 输入包含多组数据,每组数据第一行为正整数n,…
水题,排序遍历即可 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; ; int drag[maxn], kn[maxn]; int main() { int n, m, cost; while (cin >> n >> m) { && m == )break; ;i < n;i++)cin >> drag[i…
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…
C - 贪心 基础 Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Description Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The sh…
直接用白书上的翻译吧 例题1  勇者斗恶龙(The Dragon of Loowater, UVa 11292) 你的王国里有一条n个头的恶龙,你希望雇一些骑士把它杀死(即砍掉所有头).村里有m个骑士可以雇佣,一个能力值为x的骑士可以砍掉恶龙一个直径不超过x的头,且需要支付x个金币.如何雇佣骑士才能砍掉恶龙的所有头,且需要支付的金币最少?注意,一个骑士只能砍一个头(且不能被雇佣两次). [输入格式] 输入包含多组数据.每组数据的第一行为正整数n和m(1≤n,m≤20 000):以下n行每行为一个…
题目大意: 你的王国里有一条n个头的恶龙,你希望雇佣一些骑士把它杀死(即砍掉所有头).村里有m个骑士可以雇佣,一个能力值为x的骑士可以砍掉恶龙一个直径不超过x的头,且需要支付x个金币.如何雇佣骑士才能砍掉龙的所有头,且需要支付的金币最少?注意,一个骑士只能砍一个头.(且不能被雇佣两次). 输入格式 输入包含多组数据.每组数据的第一行为正整数n和m(1<=n,m<=20000):以下n行每行为一个整数,即恶龙每个头的直径:以下m行每行为一个整数,即每个骑士的能力.输入结束标志为n=m=0. 输出…
#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<string> #include<cmath> #include<map> #include<set> #include<vector> #include<algorithm> #include<stack> #in…
笔者休息娱乐. ; int n, m, a; ll solve(int n, int m) { ll ans = ; priority_queue<int, vector<int>, greater<int>> dragon, knight; rep(i, , n) { read(a); dragon.push(a); } rep(i, , m) { read(a); knight.push(a); } ; while (true) { if (dragon.empty…
题意:      一个怪物有N个头,每个头都有半径,然后有M个骑士,每个骑士能砍掉半径小于等于 X[i]的头,花费为X[i],并且一个骑士只能用一次,问砍掉怪物所有头的最小花费. 思路:       比较简单的贪心题,我是直接把头和骑士都放在一起,然后从大到小排序下,如果 权值一样的让骑士在前面,然后开始枚举每一个点,如果当前点是骑士,那么直接进栈,如 果不是骑士,那么就从栈里取出一个,这个肯定是最省钱而且肯定可以砍掉这个头的,如果 该从栈里取东西的时候栈里空了,那么就完不成任务了. #incl…
https://vjudge.net/problem/UVA-11292 题意:有n条任意个头的恶龙,你希望雇一些其实把它杀死.一个能力值为x的骑士可以砍掉恶龙一个直径不超过x的头,且需要支付x个金币.输出最少金币. 思路: 对两者进行排序.依次比较,头少的龙尽量用能力值小的骑士去砍. #include<iostream> #include<cstring> #include<string> #include<algorithm> #include<v…