- 苹果摘陶陶
- 2015-01-10 23:27:44 @
#include<cstdio>
#include<queue>
#include<stack>
using namespace std;
queue <int>A;
priority_queue <int>T;
stack <int>tt,M;
int n,m;
int main(){
scanf("%d%d",&n,&m);
for(int i=0,t;i<n;i++)
scanf("%d",&t),A.push(t);
for(int i=0,t;i<m;i++)
scanf("%d",&t),T.push(-t);
while(!T.empty())
tt.push(-T.top()),T.pop();
while(!A.empty())
{
while(!tt.empty()&&A.front()<=tt.top())
M.push(tt.top()),tt.pop();
if(!tt.empty()&&A.front()>tt.top()&&tt.top())tt.pop();
A.pop();
while(!M.empty())
tt.push(M.top()),M.pop();
}
printf("%d",tt.size());
//system("PAUSE");
return 0;
}