解题思路:
贪心
代码如下:
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 100010;
int a[N], w[N];
int ans;int main() {int n, m;cin >> n >> m;for (int i = 1; i <= n; i++)cin >> a[i];for (int i = 1; i <= m; i++)cin >> w[i];sort(a + 1, a + n + 1);sort(w + 1, w + n + 1);for (int i = 1, j = 1; i <= n && j <= m;) {if (a[i] >= w[j] ) {ans++;i++, j++;} else if (a[i] < w[j]) {i++;}}cout << ans << endl;return 0;
}