31.07.2015 Views

LITHUANIAN OLYMPIADS INFORMATICS

LITHUANIAN OLYMPIADS INFORMATICS

LITHUANIAN OLYMPIADS INFORMATICS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

40Task. Write a program to calculate the maximum profit, and then to find the minimumnumber of purchases (walking past counter) to gain that profit. There can be asituation when it is not possible to benefit and even a certain sum of money is lost. Inthis case the answer (profit) will be negative.Input. The first line of the input file contains the number of items N the customerwants to buy. In the remaining N lines there are presented prices of goods expressedin cents. The customer can not buy less than N items.Output. The first line of the output file should contain two numbers: customer’sprofit, expressed in cents, and the number of purchases (walking past counter).Examples of input and output data:Input1 Example 32232 Example 11023Output2 1-2 1221. Asterisks. (Runtime limit – to 1 sec.; processor Pentium 133 MHz). There isgiven a very long row consisting of asterisk and space symbols set in the followingorder: one asterisk, one space character, two asterisks, two space characters, threeasterisks, three space characters, etc.Task. Write a program to determine which symbol is in k’th position.Input data – one integer number– is introduced from the keyboard. It is the positionk (1 ≤ k ≤ 30000) of the symbol to be found.The Ouput –– word SPACE or ASTERISK – should be printed to the screen.222. Acquaintances. N quests (numbered from 1 to N) were invited to attendsome event.It was known in advance which persons were familiar with each other before theevent. Two guests would certainly became acquaintedwith each other during the event, if theyhad or made common acquaintance during theevent.Organizers of the event, knowing which guestswere familiar with each other, were sure that allguests would became acquainted. However one persondid not attend the event, and due to this not allthe guests became acquainted.Task. Write a program to determine the guest whodid not attend the event.ExampleInput Output742 2 72 1 42 4 54 2 3 6 72 3 62 4 52 1 4

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

Saved successfully!

Ooh no, something went wrong!