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 == '+' ){
  13. if(reader.hasNextInt()) b = reader.nextInt();
  14. if(stos.size()<10)
  15. {
  16. stos.addElement(b);
  17. System.out.println(":)");
  18. }
  19. else System.out.println(":(");
  20. }
  21. else if(a == '-' && stos.size() > 0)
  22. {
  23. System.out.println(stos.lastElement());
  24. stos.remove(stos.size()-1);
  25. }
  26. else System.out.println(":(");
  27. }
  28. }
  29. }
  30.  
Success #stdin #stdout 0.07s 711680KB
stdin
+
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
0
+
1
-
-
-
-
-
-
-
-
-
-
-
stdout
:)
:)
:)
:)
:)
:)
:)
:)
:)
:)
:(
0
9
8
7
6
5
4
3
2
1
:(