#C7040. Maximum Beauty Sum

    ID: 50868 Type: Default 1000ms 256MiB

Maximum Beauty Sum

Maximum Beauty Sum

You are given an integer (N) representing the number of flowers, followed by (N) lines. Each line contains two integers representing the type of a flower and its beauty value. Your task is to choose at most one flower from each type such that the sum of the beauty values is maximized. In other words, if multiple flowers share the same type (t), you should only select the one with the maximum beauty value (b). The answer is the sum of these maximum beauty values across all flower types.

inputFormat

The input is given via standard input (stdin). The first line contains an integer (N) denoting the number of flowers. Each of the next (N) lines contains two integers (t) and (b), where (t) is the flower type and (b) is its beauty value.

outputFormat

Output via standard output (stdout) a single integer which is the maximum possible sum of beauty values by choosing at most one flower per type.## sample

4
1 5
2 3
1 4
3 2
10