- 苹果摘陶陶
- 2017-12-07 22:17:51 @
#include <stdio.h>
#define LEN 2000
int main(void)
{
int i, j;
int m = 0, n = 0;
int apple[LEN] = {0}, taotao[LEN] = {0};
scanf("%d %d", &m, &n);
//获取高度信息
for (i = 0; i < m; ++i)
scanf("%d", &apple[i]);
for (j = 0; j < n; ++j)
scanf("%d", &taotao[j]);
//苹果摘掏掏
int max = 0, flag = 0;
for (i = 0; i < m; ++i) {
for (j = 0; j < n; ++j)
if (apple[i] > taotao[j] && taotao[j] > max)//贪心:寻找符合的最高的掏掏
{
flag = j;//记下最高的掏掏
max = taotao[j];//记下最高的高度
}
if (max > 0)
taotao[flag] = -1;//摘下掏掏
}
//计算剩下的掏掏
int count = 0;
for (j = 0; j < n; ++j)
if (taotao[j] > -1)
++count;
printf("%d\n", count);
return 0;
}