ENIGMA-0x01 (2023) - J4 (Santa Clau's most expensive gifts)

View as PDF

Submit solution

Points: 30 (partial)
Time limit: 1.0s
Blockly 5.0s
Python 3 4.0s
Memory limit: 5M
Blockly 16M
Python 3 16M

Authors:
Problem types
Allowed languages
Blockly, C, C++, Java, Pascal, Python
Santa Claus' most expensive gifts

Totos had a very strange dream last night. In his dream he was Santa's elf and he even had the role of loading all the children's the presents into Santa's sack!

Like the sly and mischievous boy he is (even in his sleep), he did the following: After finding out the value of all the presents that Santa would distribute, he made sure to put in the sack the 3 most expensive ones first, in order from most to least expensive, and afterwards, all the other presents. He had the secret hope, you see, that at least these would be left over. This way he would keep the most expensive of all for himself, the next most expensive for his friend Annoula, and the third most expensive present he would keep to... sell!

Can you help Totos in the mischief of his dream?

We want to write a program that reads from the input STDIN a positive integer N, the number of presents in the bag, followed by N positive integers P_i, separated by a line feed character ('\n'), denoting the value of each present. The program will print at the output STDOUT 3 positive integers, separated by a line feed character ('\n'), the values of the three most expensive presents, in the order in which Totos chooses them.

Constraints
  • 3 \le N \le 1.000.000
  • No present is worth more than 1000 North Pole dinars :-)
Examples
1st

STDIN

3
1
2
3

STDOUT

3
2
1
2nd

STDIN

8
10
1
9
3
10
8
1
11

STDOUT

11
10
10

Comments

There are no comments at the moment.