#K70502. Maximize Mage Power Levels
Maximize Mage Power Levels
Maximize Mage Power Levels
A mage wishes to maximize his total power by selecting exactly one item from each distinct category. Each item has a category and a corresponding power level. Your task is to compute the maximum possible sum of power levels by choosing one item per category.
Formally, given n items and their properties, let \( S = \sum_{c \in C} p_c \) where \( p_c \) is the maximum power level among all items in category \( c \), and \( C \) is the set of distinct categories. Compute \( S \).
inputFormat
The input is given via stdin with the following format:
n category_1 power_level_1 category_2 power_level_2 ... category_n power_level_n
Here, n is the number of items. Each subsequent line contains a string (the item category) and an integer (the item power level), separated by whitespace.
outputFormat
Output a single integer to stdout -- the maximum sum of power levels by selecting one item from each distinct category.
## sample3
weapon 50
armor 200
potion 30
280