蓝书P1,

很简单的一个贪心选择,用能力小的去砍小的。本来想双重循环,哎,傻逼了,直接遍历选手,碰到能砍的就砍掉。

#include <stdio.h>
#include <algorithm> using namespace std; #define MAXN 20005 int n,m;
int nn[MAXN],mm[MAXN]; int main()
{
freopen("input.txt","r",stdin);
while(scanf("%d%d",&n,&m),n+m)
{
for(int i=; i<n; i++)
scanf("%d",&nn[i]);
for(int i=; i<m; i++)
scanf("%d",&mm[i]); sort(nn,nn+n);
sort(mm,mm+m);
int ans = ;
int i=,j=;
for(i=; i<m; i++)
{
if(mm[i]>=nn[j])
{
ans+=mm[i];
if(++j==n) break;
}
}
if(j<n) printf("Loowater is doomed!\n");
else printf("%d\n",ans);
}
return ;
}

UVa(11292),贪心水题的更多相关文章

  1. PAT甲题题解-1125. Chain the Ropes (25)-贪心水题

    贪心水题,每次取最短的两个绳子合并,长度缩减成一半 #include <iostream> #include <cstdio> #include <algorithm&g ...

  2. UVA 11389 The Bus Driver Problem 贪心水题

    题目链接:UVA - 11389 题意描述:有n个司机,n个早班路线和n个晚班路线,给每个司机安排一个早班路线和一个晚班路线,使得每个早班路线和晚班路线只属于一个司机.如果一个司机早班和晚班总的驾驶时 ...

  3. 贪心水题。UVA 11636 Hello World,LA 3602 DNA Consensus String,UVA 10970 Big Chocolate,UVA 10340 All in All,UVA 11039 Building Designing

    UVA 11636 Hello World 二的幂答案就是二进制长度减1,不是二的幂答案就是是二进制长度. #include<cstdio> int main() { ; ){ ; ) r ...

  4. 【贪心算法】POJ-2393 简单贪心水题

    一.题目 Description The cows have purchased a yogurt factory that makes world-famous Yucky Yogurt. Over ...

  5. cogs 1440. [NOIP2013]积木大赛 贪心水题

    1440. [NOIP2013]积木大赛 ★★   输入文件:BlockNOIP2013.in   输出文件:BlockNOIP2013.out   简单对比时间限制:1 s   内存限制:128 M ...

  6. codeforces 672C - Recycling Bottles 贪心水题

    感觉很简单,就是讨论一下 #include <stdio.h> #include <string.h> #include <algorithm> #include ...

  7. CF 322B Ciel and Flowers 贪心水题

    B. Ciel and Flowers time limit per test 1 second memory limit per test 256 megabytes input standard ...

  8. Codeforces Round #493 (Div. 2) A. Balloons 贪心水题

    由于是输出任意一组解,可以将价值从小到大进行排序,第一个人只选第一个,第二个人选其余的.再比较一下第一个人选的元素和第二个人所选元素和是否相等即可.由于已将所有元素价值从小到大排过序,这样可以保证在有 ...

  9. hdu_2124 Flying to the Mars & hdu_1800 Repair the Wall 贪心水题

    hdu_1800 简单排一下序,从大开始把比他小的都访问一遍,ans++: #include <iostream> #include <stdio.h> #include &l ...

随机推荐

  1. PostgreSQL auto_explain

    The auto_explain module provides a means for logging execution plans of slow statements automaticall ...

  2. 几个PostgreSQL数据库操作总结

    创建表 语法:如下 create table     table_name     (column_name         column_type(parametes)options,…); 注意: ...

  3. curl命令使用(转)

    转自:http://www.cnblogs.com/sunada2005/p/3829772.html curl命令可以用来构造http请求.参数有很多,常用的参数如下: 通用语法:curl [opt ...

  4. linux下MYSQL备份与恢复

    1.用命令实现备份 数据库备份是很重要的.如果定期做好备份,这样就可以在发生系统崩溃时恢复数据到最后一次正常的状态,把损失减小到最少.MySQLl提供了一个mysqldump命令,我们可以用它进行数据 ...

  5. PAT乙级 1003. 我要通过!(20)

    答案正确”是自动判题系统给出的最令人欢喜的回复.本题属于PAT的“答案正确”大派送 —— 只要读入的字符串满足下列条件,系统就输出“答案正确”,否则输出“答案错误”. 得到“答案正确”的条件是: 1. ...

  6. z/os上的tar和gzip(3)

    前面两篇文章分别讲过了如何合并并压缩批量文件,如何解压缩并恢复批量文件, 这些问题解决了之后还剩下一个大问题,如何在网络上传输这些压缩过的文件,如果是linux的话非常简单,制定binary,然后ge ...

  7. 用jQuery创建HTML中不存在的标签元素碰到的问题

    如果你自定义了一个标签,比如<aaa></aaa> 用jQuery的写法,比如var custom_element = $('<aaa class="ee&qu ...

  8. Hibernate中Session的get和load

    hibernate中Session接口提供的get()和load()方法都是用来获取一个实体对象,在使用方式和查询性能上有一些区别.测试版本:hibernate 4.2.0. get Session接 ...

  9. 分享总结:更好地CodeReview

            代码质量分享    2016_06_24_舒琴_代码质量.key    For 代码提交人     基本原则 Review时机: 对于普通bugfix或优化,CodeReview最迟要 ...

  10. 161102、MyBatis中批量插入

    方法一: <insert id="insertbatch" parameterType="java.util.List"> <selectKe ...