#K13946. Maximum Usefulness Score

    ID: 24025 Type: Default 1000ms 256MiB

Maximum Usefulness Score

Maximum Usefulness Score

You are given N items and K kits. Each item is characterized by its weight and a usefulness score. Your task is to determine the maximum total usefulness score achievable by distributing all of the N items among the K kits such that each kit is assigned to one person.

The process of distribution is done by first sorting the items in descending order by their usefulness score and then assigning each item to the kit with the current minimum total weight. Formally, if the items are represented as tuples \((w_i, u_i)\) for weight and usefulness respectively, you have to compute the value:

[ \text{Total Usefulness} = \sum_{i=1}^{N} u_i, ]

since every item is always added to some kit. This task checks your ability to process input, sort data using custom criteria, and simulate a greedy distribution strategy.

inputFormat

The first line of input contains two integers N and K, where \(1 \le K \le N \le 100\).

Then follow N lines, each containing two integers representing the weight and usefulness score of the item respectively.

outputFormat

Output a single integer, the maximum total usefulness score achievable after distributing all items among the kits.

## sample
6 3
2 10
3 15
4 20
2 25
3 30
4 10
110

</p>