Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
133888 | baim. | 分发饼干 | C++ | 编译错误 | 0 | 0 MS | 0 KB | 636 | 2024-03-02 10:21:32 |
class Solution { public: int findContentChildren(vector<int>& g, vector<int>& s) { sort(g.begin(), g.end()); sort(s.begin(), s.end()); int maxg = g.size(),maxs = s.size(); int child = 0,cookie = 0; // while(child < g.size() && cookie < s.size()){ // if(g[child] <= s[cookie]) ++child; // ++cookie; // } for( cookie; cookie < maxs; cookie++){ if(g[child] <= s[cookie]){ child++; }; if(child>=maxg) break; } return child; } };