in a new game called the golden game, players collect gold coins. the players get only one chance to play and only one player play at a time. the score of each player is difines as the number of coins collected by the player. a player is called a golden player if he scores more than the players who played after her. score is called golden score if it is scored by a golden player. if your are given a list of (A) of integers representing scores of players in the order they played first to last. Write a program to print all the golden scores in the list by maintaining the relative order.
SAMPLE INPUT 1:
4 5 1 3 2
SAMPLE OUTPUT 1:
5 3 2
SAMPLE INPUT 2:
9 8 10 12
SAMPLE OUTPUT 2:
12
scores = list(map(int, input().split()))
golden = [scores[i] for i in range(len(scores) - 1) if scores[i] > max(scores[i + 1:])]
golden.append(scores[-1])
print(*golden)
Comments
Leave a comment