class Solution {
public:
vector<int> kWeakestRows(vector<vector<int>>& mat, int k) {
vector<pair<int, int>> idxs;
for (int i = 0; i < mat.size(); i++) {
int cnt = 0;
for (auto num : mat[i]) {
cnt += num;
}
idxs.push_back({cnt, i});
}
sort(idxs.begin(), idxs.end());
vector<int> res;
for (int i = 0; i < k; i++) {
res.push_back(idxs[i].second);
}
return res;
}
};