#K74607. Robotic Arm Simulation

    ID: 34235 Type: Default 1000ms 256MiB

Robotic Arm Simulation

Robotic Arm Simulation

You are given a series of instructions to simulate a robotic arm operating on a linear track. The arm follows the given commands, which are one of the following:

  • PICK: The arm picks up an item. It can only hold one item at a time, so if it is already holding an item, this command is ignored.
  • PLACE: The arm places the item it is holding. If it is not holding an item, this command is ignored.
  • MOVE X: The arm moves along the track by $X$ units. Here, $X$ is a non-zero integer. A positive value moves the arm to the right and a negative value moves it to the left.

Your task is to determine the final position of the arm on the track and whether it is holding an item after executing all the instructions. The final output should display the position followed by a status: "YES" if the arm is holding an item, and "NO" otherwise.

Note: The instructions are case-sensitive and the input will be provided through standard input (stdin). The output must be printed to standard output (stdout).

Examples:

Input:
5
PICK
MOVE 5
PLACE
MOVE -3
PICK

Output: 2 YES

Input: 3 MOVE 10 PICK MOVE -5

Output: 5 YES

</p>

inputFormat

The first line contains an integer n indicating the number of instructions. The following n lines each contain a command, which can be either "PICK", "PLACE", or "MOVE X" where X is a non-zero integer.

outputFormat

Output a single line containing the final position of the robotic arm and its holding status separated by a space. The status should be "YES" if the arm is holding an item or "NO" if it is not.

## sample
5
PICK
MOVE 5
PLACE
MOVE -3
PICK
2 YES