sicily 1459 The Dragon of Loowater
2014-03-03 09:41
369 查看
排序+贪心
// Problem#: 1459
// Submission#: 2720147
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/ // All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn =20010;
int A[maxn];int B[maxn];
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)==2&&n&&m)
{
for(int i=0;i<n;i++)scanf("%d",&A[i]);
for(int i=0;i<m;i++)scanf("%d",&B[i]);
sort(A,A+n);
sort(B,B+m);
int cur =0;
int cost=0;
for(int i=0;i<m;i++)
{
if(B[i]>=A[cur])
{
cost+=B[i];
if(++cur==n) break;
}
}
if(cur<n) printf("Loowater is doomed!\n");
else printf("%d\n",cost);
}
return 0;
}
// Problem#: 1459
// Submission#: 2720147
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/ // All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn =20010;
int A[maxn];int B[maxn];
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)==2&&n&&m)
{
for(int i=0;i<n;i++)scanf("%d",&A[i]);
for(int i=0;i<m;i++)scanf("%d",&B[i]);
sort(A,A+n);
sort(B,B+m);
int cur =0;
int cost=0;
for(int i=0;i<m;i++)
{
if(B[i]>=A[cur])
{
cost+=B[i];
if(++cur==n) break;
}
}
if(cur<n) printf("Loowater is doomed!\n");
else printf("%d\n",cost);
}
return 0;
}
相关文章推荐
- Sicily 1459. The Dragon of Loowater
- sicily 1459. The Dragon of Loowater
- soj 1459. The Dragon of Loowater
- The Dragon of Loowater, UVa 11292
- hdu 1902 The Dragon of Loowater
- The Dragon of Loowater
- ACM——The Dragon of Loowater(UVa 11292)
- Uva11292--------------(The Dragon of Loowater)勇者斗恶龙 (排序后贪心)
- POJ 3646 The Dragon of Loowater G++
- The Dragon of Loowater
- 文章标题 HDU 1902 :The Dragon of Loowater(贪心)
- The Dragon of Loowater(勇者斗恶龙)
- Uva 11292 The Dragon of Loowater 模拟题
- 勇者斗恶龙(The Dragon of Loowater) UVa 11292 HDU 1902
- UVa 11292 The Dragon of Loowater 【贪心】
- hdu 1092 The Dragon of Loowater
- uva11292 - The Dragon of Loowater (贪心)
- 白皮书:The Dragon of Loowater, UVa 11292,POJ 3646
- 勇者斗恶龙(The Dragon of Loowater, UVa 11292)
- HDU 1902 The Dragon of Loowater