Submit | All submissions | Best solutions | Back to list |
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.
Input
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).
Output
For each query 3, print the top element of the stack. If the stack is empty, print 'Empty!' without quotes.
Example
Input: 6
1 15
1 20
2
3
2
3 Output: 15
Empty!
Warning!
Enormous input data!
Added by: | Lucas |
Date: | 2017-02-15 |
Time limit: | 0.5s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
hide comments
|
|||||
2020-09-15 06:11:22
Hello everyone C++ time limit. Could you give me any suggestion? |
|||||
2020-08-05 20:44:28
use fast I/O in C++ for getting AC.... |
|||||
2020-05-20 13:50:04
@unlock1997 maybe because you are not printing the outputs on a new line. |
|||||
2020-05-20 02:37:06
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. |
|||||
2019-03-14 15:28:52
And also for WA, don't forget to read the output correctly and checked it before and after empty |
|||||
2018-09-01 07:10:08
for c++ , use long long int |
|||||
2018-07-24 05:11:20
I don't understand why I am getting Runtime error for this question. While I am getting the correct output for this in my code editor. |
|||||
2018-04-18 15:21:41 Ishan
For people getting WA , don't assume line will start with 1, 2 or 3. For line starting with anything else just ignore and continue to next line. |
|||||
2017-07-09 09:15:10
java time limit :( |
|||||
2017-05-31 10:21:37
please explain the problem clearly! |