BEX-wrong answer

i have tried all possible test cases, can you please tell me why could this code result in a wrong answer!

I took a quick look at you code and I don’t think you tested it properly. You are forgetting to remove books.

Example Test Case (Try your code on this):

Input:

8

4 geo

2 maths

8 history

1 python

-1

-1

0 english

-1

Correct Output:

0 python

1 maths

0 geo

Also, your algorithm does not have the right time complexity to finish all the test cases within the required time. Try thinking of a better method. Hint: Use a Stack!

Good luck and happy coding!

The correct output according to me should be
0 python
1 maths
1 geo
because the history book isn’t removed from the stack when the maths book is pulled out…Have i misunderstood the question?

According to the problem statement history book is removed from the stack.

I was trying out this problem:

I dont understand why I am getting Runtime error.
I had the same approach as in the editorial.
http://www.codechef.com/viewsolution/1855440

Please can anyone provide me some testcase which is causing SIGSEV??

Thanks

//