Shortest and clear Greedy solution

vector<int> Solution::solve(int A, vector<int> &B) {
  vector<int> ans;
  int index=min_element(B.begin(),B.end())-B.begin();
  int mini=B[index]+(A%B[index]);
  for (int i = 0; i < B.size(); i++) {
    if (B[i]<=mini and A>=B[index]) {
  return ans;

Explanation: First, we find the index with minimum strength to maximize kicks. Then we see if there is a person with strength with lower index than what we found and push that in our ans array. we then simultaneously add all values as we are iterating in the loop with this logic until our A becomes less than B[index].