Problem 2389 · Easy

Longest Subsequence With Limited Sum

Sort the numbers, build prefix sums, and binary search the longest prefix whose sum stays within each limit.

Open the interactive visualisation