蓝书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. Mac下无法安装Dragon Bones的解决方案

    在Mac下安装dragon bones 然后很郁闷的发现 没有 Exchange Manger 然后就去官网下载了一个 不过下载以后发现 怎么都认不出我的Flash CC来 一安装zxp扩展就提示我没 ...

  2. C# 在Visual Studio中一个项目有两个Main函数, 怎么设置哪个是入口?取代csc /main选项。

    namespace ConsoleApp1{class Program{static void Main(string[] args){Console.WriteLine("Program& ...

  3. Extjs treePanel 后台Json的两种构建方法

    public string json = ""; public string QueryMenuTreeJson(string ParentID, string userId) { ...

  4. 安装Git

    因为我的开发环境是Windows,那么在windows下安装Git就简单很多了.首先在,从http://msysgit.github.io/下载Git的安装程序,然后按默认选项安装即可. 安装成功之后 ...

  5. hdu5381 The sum of gcd

    莫队算法,预处理出每个数字往后的gcd情况,每个数字的gcd只可能是他的因子,因此后面最多只可能有logn种,可以先预处理出,然后套莫队算法,复杂度O(n*sqrt(n)*log(n)). 代码 #i ...

  6. Android SDK 安卓失败 提示: “Failed to fetch URL…” 的错误提示

    解决方法: 1.   打开Tools 选择 options  将  第一个复选框勾上.           (尝试一下,如果还是失败,参考2) 2.   打开本地host 文件, 在最后一行添加   ...

  7. 《zw版·Halcon-delphi系列原创教程》 2d照片-3d逆向建模脚本

    <zw版·Halcon-delphi系列原创教程> 2d照片-3d逆向建模脚本 3D逆向建模,是逆向工程的核心要素.       3D逆向建模,除了目前通用的3D点云模式,通过2D图像实现 ...

  8. 形状特征提取-Hu不变矩(转载)

    [原文部分转载]:http://blog.csdn.net/wrj19860202/archive/2011/04/16/6327094.aspx 在连续情况下,图像函数为 ,那么图像的p+q阶几何矩 ...

  9. html规范总结

    这个链接有规范的html 描述:http://nec.netease.com/standard 相关链接: 1. http://www.zhangxinxu.com/wordpress/2010/09 ...

  10. Hadoop :map+shuffle+reduce和YARN笔记分享

    今天做了一个hadoop分享,总结下来,包括mapreduce,及shuffle深度讲解,还有YARN框架的详细说明等. v\:* {behavior:url(#default#VML);} o\:* ...