#C7060. Maximum Value with Category Constraint
Maximum Value with Category Constraint
Maximum Value with Category Constraint
You are given a list of N
items. Each item is described by three integers: value, category, and a unique identifier. Your task is to select at most one item from each category such that the sum of the values of the selected items is maximized.
Formally, for each distinct category \(c\), let \(v_c\) be the maximum value among the items in that category. Then, the maximum sum is \(\sum_{c} v_c\).
Read the input from standard input and print the result on standard output.
inputFormat
The first line contains a single integer N
denoting the number of items.
The next N
lines each contain three integers value
, category
, and identifier
separated by spaces.
outputFormat
Print a single integer, the maximum possible sum of values by selecting at most one item from each category.
## sample5
10 1 1
15 2 2
20 1 3
25 3 4
30 2 5
75