轻量级前端框架助力开发者提升项目效率与性能
709
2022-08-26
Codeforces 845 D. Driving Test (模拟)
Description
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:Polycarp changes the speed of his car to specified (this event comes with a positive integer number);Polycarp’s car overtakes the other car;Polycarp’s car goes past the “speed limit” sign (this sign comes with a positive integer);Polycarp’s car goes past the “overtake is allowed” sign;Polycarp’s car goes past the “no speed limit”;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?
Input
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).
Output
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.
Examples input
111 1003 70423 12053 12061 15043 300
Examples output
2
题意
在开车时有 6 种情况:
改变速度超车限速(路标)允许超车(路标)无限速(路标)不允许超车(路标)
现在问,主角在向教练解释时最少需要忽略多少个路标才可以保证他没有违规。
思路
简单模拟题,随便写写就可以啦~
注意多个限速的路标后者会覆盖前者的数值。
AC 代码
#include
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~