有4种牌子,3-限制速度,4-可以超车,5-无限制速度,6-不可以超车。
3 5作用不会重叠,比如3之后有个5,那就不用看3.
4 5也一样。
POINT:
主要题意没读清。用栈就行了,也是水题。
#include <iostream>
#include <string.h>
#include <stack>
#include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;
#define LL long long
int main()
{
stack<int>q;
q.push(1000);
int n,ans=0;
scanf("%d",&n);
int cnt=0;
int cur=0;
for(int i=1;i<=n;i++)
{
int k;scanf("%d",&k);
int s;
if(k==1||k==3)
{
scanf("%d",&s);
}
if(k==1)
{
cur=s;
while(q.top()<cur)
{
ans++;
q.pop();
}
}
else if(k==2)
{
ans+=cnt;
cnt=0;
}
else if(k==3)
{
if(cur>s)
ans++;
else
q.push(s);
}
else if(k==4)
{
cnt=0;
}
else if(k==5)
{
q.push(1000);
}
else
cnt++;
}
printf("%d\n",ans);
}