1279 扔盘子
程序员文章站
2022-06-04 17:46:38
...
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 5e4 + 10;
const int INF = 0x3f3f3f3f;
int width[MAXN];
int m, n;
int main(){
scanf("%d%d", &n, &m);
fill(width, width + MAXN, INF);
for(int i = 1; i <= n; ++i){
scanf("%d", &width[i]);
width[i] = min(width[i], width[i - 1]);
}
int ans = 0, flag = n, plate;
for(int i = 0; i < m; ++i){
scanf("%d", &plate);
for(; flag >= 1; --flag){
if(width[flag] >= plate){
flag--;
ans++;
break;
}
}
}
printf("%d\n", ans);
return 0;
}