题目地址:http://vjudge.net/problem/UVA-11292
#include <bits/stdc++.h>
using namespace std;
const int maxn=20000+3;
int dragon[maxn],knight[maxn];
int main(int argc, char const *argv[])
{int n,m;while(scanf("%d%d",&n,&m)!=EOF,(n+m)){for(int i=0;i<n;i++)scanf("%d",&dragon[i]);for(int i=0;i<m;i++)scanf("%d",&knight[i]);if(n>m) {printf("Loowater is doomed!\n");continue;}sort(dragon,dragon+n);sort(knight,knight+m);int ans=0,p=0;bool ok;for(int i=0;i<n;i++){ //dragonok=false;for(;p<m;p++){ //knightif(knight[p]>=dragon[i]){ok=true; ans+=knight[p++];break;}}if(ok==false) break;}if(ok==false) cout<<"Loowater is doomed!"<<endl;else cout<<ans<<endl;}return 0;
}