#C799. Maximizing Cartons

    ID: 51921 Type: Default 1000ms 256MiB

Maximizing Cartons

Maximizing Cartons

You are given n books and an integer threshold p. Each book has a popularity score. Your task is to form as many cartons as possible such that the sum of the popularity scores in each carton is at least p.

You can choose one or more books to form a carton. The condition for a valid carton is that the sum of scores in that carton satisfies the inequality \(\sum_{i \in carton} \text{score}_i \ge p\). Your goal is to maximize the number of cartons you can form from the given books.

Input and Output: The input will be read from standard input and the output should be printed to standard output.

inputFormat

The input consists of the following:

  • An integer n representing the number of books.
  • An integer p representing the minimum popularity score required for each carton.
  • n integers representing the popularity scores of the books.

All values are provided in a single line or multiple lines. You need to parse them accordingly.

outputFormat

Output a single integer denoting the maximum number of cartons that can be formed.

## sample
6 10 1 2 3 4 5 6
2