Longest Subsequence With Limited Sum
Sort the numbers, build prefix sums, and binary search the longest prefix whose sum stays within each limit.
Sort the numbers, build prefix sums, and binary search the longest prefix whose sum stays within each limit.