#K37977. Maximum Items Carry Problem
Maximum Items Carry Problem
Maximum Items Carry Problem
Sonia has a collection of antique items, each with a specific weight. She has a weight capacity limit \(W\) that she cannot exceed. To maximize the number of items she can carry, Sonia plans to pick the lightest items first. Formally, given \(n\) items with weights \(w_1, w_2, \dots, w_n\), she wants to select a subset such that
\[ \sum_{i=1}^{k} w_i \le W, \]
and \(k\) is maximized.
Your task is to determine the maximum number of items Sonia can carry.
inputFormat
The first line contains two integers \(n\) and \(W\), where \(n\) is the number of items and \(W\) is the weight limit.
The second line contains \(n\) space-separated positive integers representing the weights of the items.
outputFormat
Output a single integer which is the maximum number of items that Sonia can carry without exceeding her weight limit \(W\).
## sample5 10
2 3 4 5 6
3
</p>