uva11292 Dragon of Loowater (水题)

原创 2018年04月16日 18:55:52
#include<iostream>
#include<algorithm>

int monster[20010];
int knights[20010];

using namespace std;

int main() {
	int x, y;
	cin >> x >> y;
	while (x!=0 || y!=0) {
		for (int i = 0; i < x; i++)
			cin>>monster[i];
		for (int i = 0; i < y; i++)
			cin >>knights[i];

		sort(monster,monster+x);
		sort(knights, knights + y);
		int cost = 0;
		int monsterPtr = 0;
		bool nag = false;
		for (int i = 0; i < y; i++) {
			if (monsterPtr > x-1) {
				goto end;
			}
			if (knights[i] >= monster[monsterPtr]) {
				monsterPtr++;
				cost += knights[i];
				if (monsterPtr == x) {
					cout << cost << endl;
					nag = true;
					goto end;
				}
			}
			
		}
	end:
		if (nag == false)
			cout << "Loowater is doomed!" << endl;
		cin >> x >> y;
	}
	return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lvxiangyu11/article/details/79964704

联想冲刺CMM3透明报道(2)

联想冲刺CMM3透明报道(2)肖文秀(本文转载自软件工程专家网www.21cmm.com)   编者注:联想软件事业部在2001年1月通过CMM二级评估,一年以后的今天,他们又在冲刺CMM三级。这是中...
  • gigix
  • gigix
  • 2002-03-08 09:19:00
  • 1241

uva11292 Dragon of Loowater 水题

题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=...
  • u012278856
  • u012278856
  • 2014-05-12 21:30:19
  • 320

poj3646 The Dragon of Loowater

The Dragon of Loowater Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: ...
  • u013634213
  • u013634213
  • 2014-08-21 09:50:25
  • 485

HDU 1902 The Dragon of Loowater 贪心

The Dragon of LoowaterTime Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot...
  • xky140610205
  • xky140610205
  • 2016-08-04 23:14:25
  • 627

The Dragon of Loowater(poj3646)

/*The Dragon of Loowater Description Once upon a time, in the Kingdom of Loowater, a minor nuisanc...
  • hdd871532887
  • hdd871532887
  • 2014-08-21 17:32:14
  • 676

UVa 11292 - Dragon of Loowater(排序贪心)

Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem.The shore...
  • qq_26525215
  • qq_26525215
  • 2016-04-24 23:41:46
  • 3546

UVA11292 Dragon of Loowater

题目链接:https://vjudge.net/problem/UVA-11292 题意:有n只龙,每个龙的能力为x,你有m个勇士,每个勇士的能力为y,你需要雇佣n个勇士去杀这n只龙,每个勇士雇佣费...
  • Richie_ll
  • Richie_ll
  • 2017-07-28 13:18:04
  • 116

UVA11292:Dragon of Loowater

题意:恶龙有n个头,每个头直径x,国王可以雇佣m个骑士,每个骑士能力为y,能砍半径y的头,雇佣金为y,不能重复雇佣,问最少能花费多少金币 思路:对两者进行排序,然后进行比较相加即可   #inc...
  • libin56842
  • libin56842
  • 2013-05-16 22:23:15
  • 748

uva11292 Dragon of Loowater

 Description Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowat...
  • lh1616
  • lh1616
  • 2014-08-21 15:38:49
  • 225

Uva11292 The Dragon of Loowater

Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shor...
  • hentaidesu
  • hentaidesu
  • 2015-11-18 20:43:59
  • 119
收藏助手
不良信息举报
您举报文章:uva11292 Dragon of Loowater (水题)
举报原因:
原因补充:

(最多只允许输入30个字)