Tag: problem: (C) Okabe and Boxes Solve In C/C++

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

#include <cstdio> using namespace std; int n,s,top; int main() { int i,j,ans=0; char op; scanf(“%d”,&n); for(i=j=1;i<=2*n;++i) { scanf(“%s”,op); if(op==’a’) scanf(“%d”,&s); else { if(top) { if(s==j) –top; else top=0,++ans; } ++ j; } } printf(“%dn”,ans); }

Want to stay up to date with the latest news?

We would love to hear from you! Please fill in your details and we will stay in touch. It's that simple!