#C6220. Maximum Total Beauty of Arranged Flowers
Maximum Total Beauty of Arranged Flowers
Maximum Total Beauty of Arranged Flowers
You are given N flowers, each flower is described by two integers: a color code and a beauty value. Your task is to compute the maximum total beauty when the flowers are arranged optimally.
The trick is that the arrangement process does not affect the final beauty score: every flower contributes its beauty value regardless of its color. In other words, even if multiple flowers share the same color, all of their beauty values are summed together. Therefore, the maximum total beauty is simply the sum of the beauty values of all the flowers.
Input Format: The first line contains an integer N representing the number of flowers. Each of the following N lines contains two space-separated integers, where the first integer is the color code and the second is the beauty value of the flower.
Output Format: Output a single integer which is the maximum total beauty that can be achieved.
Note: All beauty values are positive, and it is guaranteed that the final answer fits in a 64-bit signed integer.
inputFormat
The input is provided via standard input (stdin) and has the following format:
- The first line contains a single integer N — the number of flowers.
- Each of the next N lines contains two space-separated integers ci and bi — the color code and the beauty value of the flower, respectively.
outputFormat
Output via standard output (stdout) a single integer representing the maximum total beauty of the arranged flowers.
## sample5
1 4
2 3
1 2
3 5
2 1
15
</p>