搞个栈模拟一下,也才5w;
直接wa1了。。然后想到井口如果都进不去那就。。。一定GG了。
所以维护一下从井口到井底是非递增的就好了;
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
stack<int>q;
int n,m;
int main()
{
int u,x;
int tmp=1e9+1;
scanf("%d%d",&n,&m);
while(n--)
{
scanf("%d",&x);
if(tmp>=x)
{
q.push(x);
tmp=x;
}
else
{
x=tmp;
q.push(x);
}
}
int ans=0;
while(m)
{
scanf("%d",&x);
m--;
while(!q.empty()&&q.top()<x)
q.pop();
if(!q.empty())
{
q.pop();
ans++;
}
}
printf("%d\n",ans);
return 0;
}