Mock CCC '19 Contest 1 S1 - Edward's Gloves

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type
Edward Elric, the Fullmetal Alchemist.

Edward Elric has N gloves, each of which we know the specific size and whether it is a right or left glove.

It is possible to pair together two gloves if they have the same size, and if they are gloves of the opposite hands. What is the maximum number of pairs that Edward can make?

Constraints

  • 1 \le N \le 1000, where N is the number of gloves Edward has.
  • 1 \le S \le 3, S is the size of a glove.
  • Right or left gloves will be described with the character C, where C can only be R (right) or L (left).

Input Specification

The first line of input will contain a single integer, N.

The next N lines will contain an integer S_i and a character C_i, separated by a space.

Output Specification

Output a single integer, the number of pairs that can be made with the N gloves Edward has.

Sample Input 1

5
2 L
1 R
1 L
2 R
3 L

Sample Output 1

2

Sample Input 2

5
2 L
1 R
1 L
2 R
1 L

Sample Output 2

2

Comments

There are no comments at the moment.