UVa-11292 - Dragon of Loowater:简单题

原创 2015年11月20日 22:20:08
//UVa
#include<cstdio>
#include<ctype.h>
#include<cstring>
#include<fstream>
#include<iostream>
#include<algorithm>
#define LOCAL
using namespace std;
#define maxn 20005
int a[maxn],b[maxn];
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // LOCAL
    int n,m;
    while(scanf("%d%d",&n,&m)==2){
        if(n==m&&n==0) break;
        int i,j;
        for(i=0; i<n; i++)
            scanf("%d",&a[i]);
        for(i=0; i<m; i++)
            scanf("%d",&b[i]);
        if(n>m){
            printf("Loowater is doomed!\n");
            continue;
        }
        sort(a,a+n);
        sort(b,b+m);
        int ans=0;
        for(i=0,j=0; i<n&&j<m;){
            if(a[i]<=b[j]){
                ans+=b[j];
                i++; j++;
            }
            else j++;
        }
        if(i==n)
            printf("%d\n",ans);
        else
            printf("Loowater is doomed!\n");
    }
    return 0;
}

总结:

第一道原创题···对比了刘书上的代码 思路一样


版权声明:

相关文章推荐

UVa 11292 Dragon of Loowater

题目大意:有一条有很多头的龙,现在要雇佣骑士杀掉这条龙(即杀掉龙的所有头),龙有n个头,有m个骑士,每条龙头的直径为x,每个骑士的能力值为y,y>x的时候才能砍掉龙头,每个骑士只能砍一条龙头,骑士不能...

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

Once upon a time, in theKingdom of Loowater, a minor nuisance turned into a major problem. The sho...

UVa 11292 The Dragon of Loowater (贪心)

题目大意: 你的王国里有一条n个头的恶龙,你希望雇佣一些骑士把它杀死(也就是砍掉所有的头)。村里有m个骑士可以雇佣,一个能力值为 x 的骑士可以砍掉恶龙一个直径不超过 x 的头,且需要支付 x 个金...

UVa11292 The Dragon of Loowater(sort排序直接比较)

UVa11292The Dragon of Loowater(sort排序)

勇者斗恶龙(The Dragon of Loowater) UVa 11292 HDU 1902

Problem Description Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a ma...

UVA 题目11292 Dragon of Loowater

Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tu...

UVA 11292 Dragon of Loowater

题目链接: The Dragon of Loowater 题面: Problem C: The Dragon of Loowater Once upon a time, in th...

ACM——The Dragon of Loowater(UVa 11292)

ter had always been a primebreeding ground for geese. Due to the lack of predators, the geesepopulat...

uva - 11292 - Dragon of Loowater(贪心)

题意:(搬自lrj大大的书)你的国王里边有一条n个头的恶龙,你希望雇佣一些骑士把它杀死,(砍掉所有的头)。村里有m个骑士可以雇佣,一个能力值为x的骑士可以砍掉恶龙一个直径不超过x的头,且需要支付x个金...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

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