第2 - N + 1行,每行1個數,對應井的寬度Wi(1 <= Wi <= 10^9)。
第N + 2 - N + M + 1行,每行1個數,對應盤子的寬度Di(1 <= Di <= 10^9) Output輸出最終落到井內的盤子數量。 Sample Input
7 5 5 6 4 3 6 2 3 2 3 5 2 4
Sample Output
4
AC代碼:
#include<cstdio>
#include<algorithm>
using namespace std;
int a[50000+5],b[50000+5];
int main()
{
int n,m;
scanf("%d %d",&n,&m);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
for(int i=1;i<=m;i++)
scanf("%d",&b[i]);
for(int i=2;i<=n;i++)
a[i]=min(a[i-1],a[i]);
int ans=0,j=n;
for(int i=1;i<=m;i++)
{
for(;j>=1;)
{
if(a[j]>=b[i])
{
ans++;
j--;
break;
}
j--;
}
// if(j==0) break;
}
printf("%d\n",ans);
return 0;
}