#K14726. Maximum Items Purchase

    ID: 24199 Type: Default 1000ms 256MiB

Maximum Items Purchase

Maximum Items Purchase

You are given a budget \(B\) and a list of item prices. Your task is to determine the maximum number of items you can purchase such that the total cost does not exceed \(B\). You should select items in a way that maximizes the count of items you can buy. Note that the store may offer multiple items with the same price, and each item is considered individually.

Example: For a budget of 50 and items with prices [1, 12, 5, 111, 200, 1000, 10], one optimal way is to buy items with prices 1, 5, 10, and 12, yielding a total of 4 items (since \(1 + 5 + 10 + 12 = 28 \leq 50\)).

inputFormat

The input consists of two lines:

  • The first line contains an integer \(B\) representing the budget.
  • The second line contains space-separated positive integers, each representing the price of an item.

outputFormat

Output a single integer which is the maximum number of items that can be bought without exceeding the budget.

## sample
50
1 12 5 111 200 1000 10
4

</p>