31.07.2015 Views

LITHUANIAN OLYMPIADS INFORMATICS

LITHUANIAN OLYMPIADS INFORMATICS

LITHUANIAN OLYMPIADS INFORMATICS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Output. N integers (numbers of jobs must sorted in the order of their performance)– should be written to the output file, one number per line.55STAGE IIIPART IIJUNIOR DIVISION244. Slips With Numbers. The following experiment is carried out. There aretaken N numbered paper slips and any natural number from 1 to 100 is written oneach slip. Written numbers can repeat. All the slips are thrown to some box.Then two randomly selected slips are taken from the box. Their numbers (not thenumbers written on them!) and the sum of the numbers written on the two slips arewritten down. Then the first slip is thrown away, and the second one is put back to thebox. The action is repeated until only two slips remain in the box.When the last two slips remain in the box, the product and the sum of the numberswritten on the slips is calculated and noted down. The numbers of the slips are notmentioned. The experiment is over with it.Task. Write a program, which, according to the notes of experiment, would determinewhich number, was written on each slip.If several solutions are possible, find the one where the number written on the firstpaper slip is the least.Input. The first line of the input file contains the number of slips N, 3≤£N≤£10000.In the remaining N-2 lines there are written three numbers per line.The first one is the number of the first slip (which is thrown away later) from the firstdrawn pair, the second one is the number of the second slip from the same pair (which isput back to the box), and the third number is sum of numbers written on these slips.In the next line there are written data about the second drawn pair of slips, in thenext other line there are written data about the third pair and etc.In the last two lines (in the Nth and in the N+1) of the input file there are writtenthe product and the sum of numbers, written on the last two slips.Output. The output file must contain N lines, one number per line. Write the numberwritten on the first slip to the first line, the number written on the second slip to thesecond line and etc.ExampleInput Output Explanation5 102 1 40 304 3 70 303 5 90 40600 6070After drawing the first pair the sum 40 is obtained(30+10=40).After drawing the second pair the sum 70 is obtained(30+40=70). After drawing the third pair the sum 90 isobtained (30+60=90). The product of the last two leafletsis equal to 600 (60´´10=600), and their sum is 70(60+10=70).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!