#63751. [ USACO 2022 Open Bronze]Counting Liars

[ USACO 2022 Open Bronze]Counting Liars

暂无测试数据。

英文题面

Bessie the cow is hiding somewhere along the number line. Each of Farmer John's $N$ other cows ($1\le N\le 1000$) have a piece of information to share: the $i$-th cow either says that Bessie is hiding at some location less than or equal to $p_i$, or that Bessie is hiding at some location greater than or equal to $p_i$ ($0\le p_i\le 10^9$).

Unfortunately, it is possible that no hiding location is consistent with the answers of all of the cows, meaning that not all of the cows are telling the truth. Count the minimum number of cows that must be lying.

译文

奶牛 Bessie 躲在数轴上的某处。Farmer John 的 $N$ 头奶牛($1\le N\le 1000$)中的每头奶牛都有一条信息要分享:第 $i$ 头奶牛说 Bessie 躲在小于或等于 $p_i$ 的某个位置,或者说 Bessie 躲在大于或等于 $p_i$ 的某个位置($0\le p_i\le 10^9$)。

不幸的是,可能不存在躲藏位置与所有奶牛的回答均一致,这意味着并非所有奶牛都在说真话。计算在撒谎的奶牛的最小数量。

输入格式

The first line contains $N$.

The next $N$ lines each contain either L or G, followed by an integer $p_i$. L means that the $i$-th cow says that Bessie's hiding location is less than or equal to $p_i$, and G means that $i$-th cow says that Bessie's hiding location is greater than or equal to $p_i$.

输入的第一行包含 $N$。

以下 $N$ 行每行包含字符 L 或 G,之后是一个整数 $p_i$。L 表示第 $i$ 头奶牛说 Bessie 的躲藏位置小于或等于 $p_i$,而 G 表示第 $i$ 头奶牛说 Bessie 的躲藏位置大于或等于 $p_i$。

输出格式

The minimum number of cows that must be lying. 输出在撒谎的奶牛的最小数量。

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