uva 11292 - Dragon of Loowater

做一两个水题怡情一下!

 1 #include<cstdio>
 2 #include<algorithm>
 3 #define maxn 20009
 4 using namespace std;
 5 int a[maxn],b[maxn];
 6 
 7 int main()
 8 {
 9     int n,m;
10     while(scanf("%d%d",&n,&m)&&(n+m))
11     {
12         for(int i=0;i<n;i++)scanf("%d",&a[i]);
13         for(int i=0;i<m;i++)scanf("%d",&b[i]);
14         if(n>m){puts("Loowater is doomed!");continue;}
15         sort(a,a+n);
16         sort(b,b+m);
17         int j=0,ans=0;
18         for(int i=0;i<m;i++)
19         {
20             if(b[i]>=a[j]){j++;ans+=b[i];}
21             if(j==n)break;
22         }
23         if(j<n)puts("Loowater is doomed!");
24         else printf("%d\n",ans);
25     }
26     return 0;
27 }
View Code

 

posted @ 2013-10-25 12:47  Yours1103  阅读(114)  评论(0编辑  收藏  举报