标签:
1 /*UVa 11292 Dragon of Loowater*/ 2 #include<iostream> 3 #include<cstdio> 4 #include<cmath> 5 #include<algorithm> 6 using namespace std; 7 int n,m; 8 int main(){ 9 while(scanf("%d%d",&n,&m) && n!=0 && m!=0){ 10 int i; 11 int a[20050]={0};//龙头直径 12 int p[20050]={0};//骑士能力 13 for(i=1;i<=n;i++)scanf("%d",&a[i]); 14 for(i=1;i<=m;i++)scanf("%d",&p[i]); 15 sort(a+1,a+n+1);sort(p+1,p+m+1); 16 int num=1; 17 int sum=0; 18 for(i=1;i<=m;i++){ 19 if(p[i]>=a[num]) 20 { 21 sum+=p[i]; 22 num++; 23 } 24 if(num==n+1)break; 25 } 26 if(i==m+1)printf("Loowater is doomed!\n"); 27 else printf("%d\n",sum); 28 } 29 return 0; 30 }
标签:
原文地址:http://www.cnblogs.com/AwesomeOrion/p/5335346.html