提交时间:2024-03-02 10:36:34
运行 ID: 133917
#include<bits/stdc++.h> using namespace std; int main() { int g,int s; Arrays.sort(g); Arrays.sort(s); int i = 0; int j = 0; int res = 0; while(i<g.length&&j<s.length){ if(s[j]>=g[i]){//如果当前饼干满足当前孩子的需求,则res++,并取下一个孩子 res++; i++; } j++;//无论满足或不满足都要取下一个饼干 } cout<<res; }