Affiliate Disclosure: This post contains Amazon affiliate links. If you purchase through these links, eBlogarithm may earn a commission at no extra cost to you. Prices and availability are subject to change.
#include <cstdio>
using namespace std;
int n,s[300005],top;
int main()
{
int i,j,ans=0;
char op[15];
scanf(“%d”,&n);
for(i=j=1;i<=2*n;++i)
{
scanf(“%s”,op);
if(op[0]==’a’)
scanf(“%d”,&s[++top]);
else
{
if(top)
{
if(s[top]==j) –top;
else top=0,++ans;
}
++ j;
}
}
printf(“%d\n”,ans);
}
📦 Looking for Codeforces Round 420 Div Problem Okabe? Check the best deals on Amazon.
🛒 Shop Codeforces Round 420 Div Problem Okabe on Amazon
As an Amazon Associate, eBlogarithm earns from qualifying purchases. Prices and availability are subject to change.
Affiliate Disclosure: This post contains Amazon affiliate links. If you purchase through these links, eBlogarithm may earn a commission at no extra cost to you. Prices and availability are subject to change.
#include <cstdio>
using namespace std;
int n,s[300005],top;
int main()
{
int i,j,ans=0;
char op[15];
scanf(“%d”,&n);
for(i=j=1;i<=2*n;++i)
{
scanf(“%s”,op);
if(op[0]==’a’)
scanf(“%d”,&s[++top]);
else
{
if(top)
{
if(s[top]==j) –top;
else top=0,++ans;
}
++ j;
}
}
printf(“%d\n”,ans);
}
📦 Looking for Codeforces Round 420 Div Problem Okabe? Check the best deals on Amazon.
🛒 Shop Codeforces Round 420 Div Problem Okabe on Amazon
As an Amazon Associate, eBlogarithm earns from qualifying purchases. Prices and availability are subject to change.