Mobile coding works. A laptop is faster for long sessions.

Problem

A natural number N is read, followed by N integer values, one at a time. Build a stack implemented on an array with index top, applying the following rule:

  • if the current value is not already on the stack, push it;
  • if the current value is already on the stack (at any level), ignore it.

After processing all N values, print the contents of the stack from top to bottom, values separated by single spaces. If the stack is empty, print the word VIDA.

Do not use STL containers.

Input format

Input input.txt

The first line contains `N`. The second line contains the `N` values separated by spaces. If `N` is `0`, the second line may be absent. - `0 <= N <= 1000`; - values are integers, `0 <= val <= 1_000_000`.

Output format

Output output.txt

The program prints on a single line either the stack elements (from top to bottom) separated by single spaces, or the word `VIDA`.

Example

input
7

3 1 4 1 5 9 3
output
9 5 4 1 3

Ready to solve this challenge?

Create a free account to write code, submit solutions, and track your progress.

⌨️ Keyboard Shortcuts

Code Editor
Run Code
Ctrl Enter
Submit Code
Ctrl Shift Enter
Format Code
Shift Alt F
Toggle Comment
Ctrl /
Undo
Ctrl Z
Redo
Ctrl Y
Navigation
Global Search
/
Show Shortcuts
?
Close Modal
Esc

🔍 Interactive Debugger

0 / 0

Analyzing your code...

📦 Variables

No variables yet

📚 Call Stack
main() line 1
📤 Output