fork download
  1. import java.util.*;
  2.  
  3. class Glowna {
  4. public static void main(String[] args){
  5. char a = ' ';
  6. int b = 0;
  7. Vector<Integer> stos = new Vector<Integer>();
  8. Scanner reader = new Scanner(System.in);
  9. while(reader.hasNext())
  10. {
  11. a = reader.next().charAt(0);
  12. if(a == '+' && stos.size()<10){
  13. if(reader.hasNextInt()) b = reader.nextInt();
  14. stos.addElement(b);
  15. System.out.println(":)");
  16. }
  17. else if(a == '-' && stos.size() > 0)
  18. {
  19. System.out.println(stos.lastElement());
  20. stos.remove(stos.size()-1);
  21. }
  22. else System.out.println(":(");
  23.  
  24. }
  25. }
  26. }
  27.  
Success #stdin #stdout 0.06s 711680KB
stdin
+
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
0
+
1
-
-
-
-
-
-
-
-
-
-
-
stdout
:)
:)
:)
:)
:)
:)
:)
:)
:)
:)
:(
:(
0
9
8
7
6
5
4
3
2
1
:(