int minMoves(vectorarr, int n, int k) { sort(arr.begin(), arr.end()); int i = 0, j = n - 1; int moves = 0; while (i <= j) { if (arr[i] + arr[j] <= k) { i++; } j--; moves++; } return moves; }