304420: CF845D. Driving Test
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Driving Test
题意翻译
Polycarp刚尝试通过驾驶考试。他跑过直道,有四种类型的标识牌。 1、**速度限制**:此符号带有一个正整数,表示汽车的最大速度(取消此类型上一个符号的动作); 2、**允许超车**:这个标志意味着一些车遇到它后,它可以超过任何其他车(这句话对着样例意会一下); 3、**无速度限制**:此标志取消限速(如果有的话)(汽车可以在此标志后以任意速度移动 ; 4、**取消超车允许**:一些车在这个标志后不能超过任何其他车。 Polycarp通过了这些标志,每个新标志都取消了之前所有标志(速度限制/超车)的动作。 有可能两个或多个“没有超车允许”的标志一个接一个地出现,它们之间没有“超车允许”标志。这个说明适用于“无速度限制”和“超车允许”标志。 在乘坐开始时允许超车并且没有速度限制。 现在按时间顺序给出了一系列事件 - 在乘坐过程中发生在Polycarp的事件。有以下类型的事件: Polycarp将他的汽车速度改为指定(用一个正整数表示) ; Polycarp的车超越了另一辆车; Polycarp的汽车经过了“限速”标志(此标志带有正整数); Polycarp的汽车经过“超车允许”标志; Polycarp的汽车经过了“无限速”; Polycarp的赛车经过了“不允许超车”; 保证按时间顺序的第一个事件是类型1的事件(Polycarp将他的汽车的速度改为指定的)。 在考试结束后,Polycarp可以通过告诉驾驶教练他没有注意到某些迹象来证明他的违规行为是正当的。 Polycarp现在要证明他的违规行为是正当的,那么他最少要说的自己没有注意到的标识数量是多少? # 输入输出格式 ## 输入格式 第一行一个整数 $n(1\le n \le 2 \times 10^5)$,表示事件数量。 接下来的 $n$ 行中的每一行以整数 $t$ 开始 $(1 \le t \le 6)$ 即事件的类型。 在第一种和第三种类型的查询中跟随着整数 $s(1 \le s \le 300)$。 保证按时间顺序的第一个事件是类型 $1$ 的事件(Polycarp 将他的汽车的速度改为指定的)。 注:如果它是第一种类型的查询,那么它是 Polycarp 汽车的新速度,如果它是第三种类型的查询,那么是新的速度限制 ## **输出格式:** 输出能使他证明他的违规行为是正当的的没有注意到的标识数量的最小值。 ## **样例解释:** 在第一个例子中,Polycarp应该说他没有注意到限速为 70 的“速度限制”标志和第二个限速为 120 的“速度限制”标志。 在第二个例子中,Polycarp没有违反任何规则。 在第三个例子中,Polycarp应该说他没有注意到在“超车允许”标志之后出现的两个“禁止超车”。题目描述
Polycarp has just attempted to pass the driving test. He ran over the straight road with the signs of four types. - speed limit: this sign comes with a positive integer number — maximal speed of the car after the sign (cancel the action of the previous sign of this type); - overtake is allowed: this sign means that after some car meets it, it can overtake any other car; - no speed limit: this sign cancels speed limit if any (car can move with arbitrary speed after this sign); - no overtake allowed: some car can't overtake any other car after this sign. Polycarp goes past the signs consequentially, each new sign cancels the action of all the previous signs of it's kind (speed limit/overtake). It is possible that two or more "no overtake allowed" signs go one after another with zero "overtake is allowed" signs between them. It works with "no speed limit" and "overtake is allowed" signs as well. In the beginning of the ride overtake is allowed and there is no speed limit. You are given the sequence of events in chronological order — events which happened to Polycarp during the ride. There are events of following types: 1. Polycarp changes the speed of his car to specified (this event comes with a positive integer number); 2. Polycarp's car overtakes the other car; 3. Polycarp's car goes past the "speed limit" sign (this sign comes with a positive integer); 4. Polycarp's car goes past the "overtake is allowed" sign; 5. Polycarp's car goes past the "no speed limit"; 6. Polycarp's car goes past the "no overtake allowed"; It is guaranteed that the first event in chronological order is the event of type $ 1 $ (Polycarp changed the speed of his car to specified). After the exam Polycarp can justify his rule violations by telling the driving instructor that he just didn't notice some of the signs. What is the minimal number of signs Polycarp should say he didn't notice, so that he would make no rule violations from his point of view?输入输出格式
输入格式
The first line contains one integer number $ n $ ( $ 1<=n<=2·10^{5} $ ) — number of events. Each of the next $ n $ lines starts with integer $ t $ ( $ 1<=t<=6 $ ) — the type of the event. An integer $ s $ ( $ 1<=s<=300 $ ) follows in the query of the first and the third type (if it is the query of first type, then it's new speed of Polycarp's car, if it is the query of third type, then it's new speed limit). It is guaranteed that the first event in chronological order is the event of type $ 1 $ (Polycarp changed the speed of his car to specified).
输出格式
Print the minimal number of road signs Polycarp should say he didn't notice, so that he would make no rule violations from his point of view.
输入输出样例
输入样例 #1
11
1 100
3 70
4
2
3 120
5
3 120
6
1 150
4
3 300
输出样例 #1
2
输入样例 #2
5
1 100
3 200
2
4
5
输出样例 #2
0
输入样例 #3
7
1 20
2
6
4
6
6
2
输出样例 #3
2