P8267 [USACO22OPEN] Counting Liars B
Description
The cow Bessie is hiding somewhere on the number line. Each of Farmer John’s $N$ cows ($1\le N\le 1000$) has a piece of information to share: the $i$-th cow says that Bessie is hiding at some position less than or equal to $p_i$, or says that Bessie is hiding at some position greater than or equal to $p_i$ ($0\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 $N$.
The next $N$ lines each contain a character L or G, followed by an integer $p_i$. L means the $i$-th cow says Bessie’s hiding position is less than or equal to $p_i$, while G means the $i$-th cow says Bessie’s hiding position is greater than or equal to $p_i$.
Output Format
Output the minimum number of cows that are lying.
Explanation/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