Competitive Programming With Titans

Competitive Programming With Titans

In this article, I have decided to write a serie of programming challenges related to the anime serie Attack on Titans (Shingeki no Kyojin).

Problem 1 : Shiganshina Attack

As a member of the Paradise island, you were brilliant enough to join the Engineering team of the island and fight the mighty titans that destroy everything that comes by their path. But today, Wall Maria was attacked by the Armored Titan and a breach was therefore created for other titans to attack the Shiganshina Distric.

image

You were designated to solve this emergency issue by helping Commandor Erwin to eliminate the titans from the top of the wall. But since the Commandor’s team is short of gas, he prefers his team to attack titans that are similar in height rather than jumping from a big one to a small one and vice-versa.

Your goal is to sort the titans from the biggest ones to the smaller ones by giving him the position of the ones to attack.

  1. If two or more titans share the same height, then they should be attacked from the one to the east going to the to the west. Positions start from 1 at east to N at west.

The input consists on a first line determining the number of titans to attack and a second line containing the height of each titan as an integer in meters taken from east to west and separated by a single space.

The output should consist on a single line containing the positions of the titans to attack first, the first element of the line should be the position of the smallest titan to attack first and the last element should be the position of the biggest titan to attack last.

Input : 10 
        2 4 8 12 5 4 7 9 20 5

Output : 1 2 6 5 10 7 3 8 4 9