https://i1.wp.com/eblogarithm.com/wp-content/uploads/2017/08/Codeforces-Round-420-Div-2-problem-C-Okabe-and-Boxes-Solution-In-CC1.png?fit=640%2C360

Codeforces Round #420 (Div. 2), problem: (C) Okabe and Boxes Solution In C/C++

#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);
}

(Visited 25 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: