提交时间:2024-03-02 10:23:59

运行 ID: 133892

#include<bits/stdc++.h> using namespace std; int findContentChildren(vector<int>& g, vector<int>& s) { sort(g.begin(), g.end()); sort(s.begin(), s.end()); int m = g.size(), n = s.size(); int count = 0; for (int i = 0, j = 0; i < m && j < n; i++, j++) { while (j < n && g[i] > s[j]) { j++; } if (j < n) { count++; } } cout<<count; }