ΠΔΠ-22 (2010) - Phase A (hydrogen)

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem types
Allowed languages
C, C++, Java, Pascal, Python
Hydrogen

It is now a common assumption that the existing development model, beyond all other distortions, causes a terrifying degradation in our planet's environment. Reducing hydrocarbon consumption and limiting the amount of emitted carbon dioxide (CO_2) are top priorities for humanity. The use of hydrogen (H_2), which can be produced cheaply from seawater by electrolysis, the electrical loads of which can be provided by photovoltaic elements, is a promising solution. The combination of hydrogen (H_2) with Oxygen (O_2) occurs through a powerful exothermic reaction, and the only byproduct is water! (2H_2 + O_2 \longrightarrow 2H_2O). The controlled reaction in "hydrogen cells" produces electrical current.

A collaboration of Greek Universities, e-TEE, and EPY built some experimental hydrogen cars with advanced power conversion, mechanical, and electronic systems for optimal performance. In order to test their behavior under real driving conditions, with the help of the network of Greek Universities and TEIs, every fault detected in each of the 10.000 separate parts of the car is recorded in a central information system. Faults not attributable to the driver are checked and recorded, while those "attributed to the driver" are not recorded.

Problem:

Develop a problem in one of the IOI languages that, after reading the fault reports for each part, will produce a file with the number of parts that experienced a fault (not attributable to the driver) and the corresponding parts of the car, sorted in descending order of fault reports.

Input Files:

The input files named hydrogen.in are text files with the following structure: The first line contains an integer, the number C of parts for which there were fault reports (10 \le C \le 10.000).

The next C lines each contain two integers separated by a space: the part number and the total number of faults detected for that part.

Output Files:

The output files named hydrogen.out are text files with the following structure: The first line contains an integer, the number L of parts that experienced manufacturer responsibility faults (0 \le L \le 10.000).

The next L lines each contain one integer, the part number that experienced a fault, sorted in descending order based on the frequency of faults.

Examples of input-output files
1st

STDIN (hydrogen.in)

10
1 34
2 11
17 2
18 1
19 5
20 6
9001 0
1111 0
701 0
111 11

STDOUT (hydrogen.out)

7
1
2
111
20
19
17
18
2nd

STDIN (hydrogen.in)

20
11 1
22 0
33 2
44 0
55 3
66 0
77 4
88 0
99 5
111 0
222 6
333 0
444 7
555 0
666 8
777 0
888 9
999 0
1111 10
2222 11

STDOUT (hydrogen.out)

11
2222
1111
888
666
444
222
99
77
55
33
11
Notes:
  1. The codes of the various car parts appear only once in the input file.
  2. If two codes have the same frequency of fault occurrences, they will be displayed in ascending order in the output file.

Comments

There are no comments at the moment.