#P8267. [USACO22OPEN] Counting Liars B

[USACO22OPEN] Counting Liars B

Problem Description

The cow Bessie is hiding somewhere on the number line. Each of Farmer John’s NN cows (1N10001\le N\le 1000) has a piece of information to share: the ii-th cow says that Bessie is hiding at some position less than or equal to pip_i, or says that Bessie is hiding at some position greater than or equal to pip_i (0pi1090\le p_i\le 10^9).

Unfortunately, there may be no hiding position that is consistent with all cows’ answers, which means not all cows are telling the truth. Compute the minimum number of cows that are lying.

Input Format

The first line of input contains NN.

The next NN lines each contain a character L or G, followed by an integer pip_i. L means the ii-th cow says Bessie’s hiding position is less than or equal to pip_i, while G means the ii-th cow says Bessie’s hiding position is greater than or equal to pip_i.

Output Format

Output the minimum number of cows that are lying.

2
G 3
L 5
0
2
G 3
L 2
1

Hint

[Sample Explanation 1]

It is possible that no cows are lying.

[Sample Explanation 2]

At least one cow is lying.

Translated by ChatGPT 5