STACKEZ - Easy Stack
You have an empty stack and you are given some queries. These queries are the basic stack operations such as Push, Pop, and printing the Top element. Now, you should process the given queries.
First line contains an integer T (0 <= T <= 106).
Each of the next T lines contains a query based on these formats.
1 n : Push n (0 < n <= 109) to the top of the stack.
2 : Pop an element from the top of the stack. If the stack is empty, do nothing.
3 : Print the top element of the stack (see Output Format).
For each query 3, print the top element of the stack. If the stack is empty, print 'Empty!' without quotes.
3 Output: 15
Enormous input data!
use fast I/O in C++ for getting AC....
@unlock1997 maybe because you are not printing the outputs on a new line.
it's passed when I code in C++ and I don't know why I receive "time limit exceeded" when I code in Java with the same code from the C++ one.
And also for WA, don't forget to read the output correctly and checked it before and after empty
for c++ ,
I don't understand why I am getting Runtime error for this question.
For people getting WA , don't assume line will start with 1, 2 or 3.
java time limit :(
please explain the problem clearly!