200. Asteroid Collision
MediumStackSimulation
Positive values move right, negative move left; the absolute value is the size. When two meet, the smaller explodes (both if equal). Print the remaining asteroids, or EMPTY.
Input format
Line 1: n Line 2: n non-zero integers
Output format
The survivors, or EMPTY.
Example 1
Input
3 5 10 -5
Output
5 10
Example 2
Input
2 8 -8
Output
EMPTY
Constraints
1 ≤ n ≤ 10⁴
Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.
Loading the MyLoginn IDE…