标签:
#include <vector> #include <list> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> using namespace std; typedef long long LL; #define CLR(x,y) memset((x),(y),sizeof((x))) #define FOR(x,y,z) for(int (x)=(y);(x)<(z);++(x)) #define FORD(x,y,z) for(int (x)=(y);(x)>=(z);--(x)) const int maxn = 20000 + 100; int a[maxn],b[maxn]; int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int n,m; while(~scanf("%d%d",&n,&m) && n + m){ FOR(i,0,n) scanf("%d",a + i); FOR(i,0,m) scanf("%d",b + i); sort(a,a+n);sort(b,b+m); int j = 0,ans = 0; FOR(i,0,m){ if(b[i] >= a[j]){ ans += b[i]; if(++j == n) break; } } if(j == n) printf("%d\n",ans); else puts("Loowater is doomed!"); } return 0; } |
[2016-03-14][UVA][11292][Dragon of Loowater]
标签:
原文地址:http://www.cnblogs.com/qhy285571052/p/5276951.html