uva11292 Dragon of Loowater
水题,排序遍历即可
#include<iostream>
#include<cstdio>
#include<algorithm> using namespace std; const int maxn = ;
int drag[maxn], kn[maxn];
int main()
{
int n, m, cost;
while (cin >> n >> m) {
if(n == && m == )break;
for (int i = ;i < n;i++)cin >> drag[i];
for (int i = ;i < m;i++)cin >> kn[i];
sort(drag, drag + n);
sort(kn, kn + m);
int cur = ;
cost = ;
for (int i = ;i < m;i++) {
if (kn[i] >= drag[cur]) {
cost += kn[i];
if (++cur == n)break;
}
}
if (cur < n)cout << "Loowater is doomed!" << endl;
else cout << cost << endl;
}
return ;
}
uva11292 Dragon of Loowater的更多相关文章
- 勇者斗恶龙UVa11292 - Dragon of Loowater
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=s ...
- uva11292 Dragon of Loowater(排序后贪心)
#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #inc ...
- uva-----11292 The Dragon of Loowater
Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...
- The Dragon of Loowater
The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into ...
- uva 11292 Dragon of Loowater (勇者斗恶龙)
Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...
- UVA它11292 - Dragon of Loowater
Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...
- UVA 11292 Dragon of Loowater(简单贪心)
Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...
- Dragon of Loowater
option=com_onlinejudge&Itemid=8&page=show_problem&problem=2267" style="color:b ...
- 贪心/思维题 UVA 11292 The Dragon of Loowater
题目传送门 /* 题意:n个头,m个士兵,问能否砍掉n个头 贪心/思维题:两个数组升序排序,用最弱的士兵砍掉当前的头 */ #include <cstdio> #include <c ...
随机推荐
- esxi 升级
开启ssh esxcli software vib install -d="/vmfs/volumes/53034105-a8b88330-c096-40f2e993407b/update- ...
- JavaScript数据类型之隐式类型转换
JavaScript的数据类型分为七种,分别为null,undefined,boolean,string,number,object,symbol ( ECMAScript 2015新增).objec ...
- Arcgis Server 10.2默认服务端口号修改方法
本人安装Arcgis Server 10.2之后发布了一个地图服务,该服务默认使用的端口号是6080,本人使用的是教育网,使用教育网均能正常使用该服务,但是使用电信或者移动网络均不能正常访问该网站. ...
- H5页面在QQ和微信上分享,为什么不能自定义设置图片和摘要?
[记录]title标签中的页面标题为抓取标题.body内第一个img标签内的图片为自动抓取缩略图,图片宽高要大于300,如果不希望显示出来,将标签宽高皆设置为0.摘要显示为来源链接,如需自定义需要通过 ...
- cAdvisor0.24.1+InfluxDB0.13+Grafana4.0.2搭建Docker1.12.3 Swarm集群性能监控平台
目录 [TOC] 1.基本概念 既然是对Docker的容器进行监控,我们就不自己单独搭建cAdvisor.InfluxDB.Grarana了,本文中这三个实例,主要以Docker容器方式运行. 本 ...
- Json格式应用
Json格式在用于数据存储方面比xml有着空间上的优势,Json格式又主要分为两种格式:名称/值 对 和数组. 在我的业务环境中需要先把一种空间比较小的格式. 测试如下: 取数据库中的一张表然后生成两 ...
- css 多个不定数量提交按钮居中显示,纯css解决
前几天在公司修改一个css 多个按钮居中问题,其实这样的问题很多前端程序员都遇到过,举个例子吧: 在一行中有三个按钮或是两个按钮...个数不定,然后间距固定:然后就有很多人把所有按钮放到一个div中, ...
- [开源项目]Hibernate基本使用
开源项目(1)Hibernate基本使用 Hibernate介绍 Hibernate是一个开放源代码的对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,使得Java程序员可以随心所欲的使用对象 ...
- EMC起步:华为交换机拆解
[作者:byeyear Email:east3@163.com 转载请保留此行] 1. 静电抗扰 理想情况下,我们的系统是一个中空且密闭的金属盒子,根据电磁场理论,外界的任何静电源都不可能 ...
- 待研究:insert客商账户触发器增加条件提示为空
增加客商时候重名不给保存,增加修改条件提示找不到