Puzzled


Submit solution

Points: 5
Time limit: 5.0s
Memory limit: 256M

Author:
Problem type

Harry is a relatively new player to PUBG. He wants to maximize his chances of winning. The game presents him with loot boxes that contain a number of weapons. There might be multiple guns of the same variant, but with its own number of bullets available. Harry can take only one gun per variant and can't take bullets from a gun that has not been taken.

Your task is to find the number of guns taken by Harry along with the maximum number of bullets for that variant.

Input Description:

The first line of 'n', the number of weapons in the loot box. The next n line contains 'a' and 'b', each of which are separated by space. The string 'a' determines the variant of the gun and the number 'b' determines the number of bullets in that gun.

CONSTRAINTS

  • 2 ≤ N ≤ 10^5
  • length of string 'a' ≤ 20
  • b ≤ 5 * 10^3

Output Description:

Print the maximum number of bullets that can be taken across all variants.

Sample Input:

4
Pistol 13
UMZ 20
Pistol 15
Sniper 40
Sniper 20

Sample Output:

75

Comments

There are no comments at the moment.