做一两个水题怡情一下!
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 ",ans); 25 } 26 return 0; 27 }