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.

to crossing c, then number of crossing c is written. The last number in the line is thenumber of crossing c.Each line that describes dead-end begins with letter “A”. Two integers followthen: number of crossing from which there is a path leading to the dead-end and thevalue of jewel v (v – integer, 1 ≤ v ≤ maxint) that is hidden in the dead-end..Each letter and number are separated by a single space.Example:1. If crossing number 3 is being described inthe input data and you can go to it from thecrossing 5, the following line will describethe crossing 3:K 5 32. If the entrance to the maze has a number 4,the following line will describe the entrance:K 0 43. If there is a path to some dead-end from thecrossing 2, and the value of the jewel hiddenin the dead-end is 4, the line will be:A 2 4Output. The value of the jewel (single integer)should be printed to the screen.Input8 9K 10 9K 4 7A 9 5K 5 3A 3 3A 1 8K 0 4A 2 4K 4 5K 4 10A 1 7A 3 2K 7 1A 3 4A 9 8K 10 2A 7 5ExampleOutput5188. Presidential Election. Well-known politician K. Klevas decided to run forpresident. His team counts his popularity rating every day. Unfortunately the situationchanges, and rating goes up or down every day.The team of K. Klevas is willing to announce to the press such a summary ofpopularity rating changes that would not compromise the candidate. It is too dangerousto falsify data but it is possible to select several days and to make public only theratings of those selected days. While making the list of days (and ratings duringthese days) for the media, the days must be sorted in chronological order, but it is notnecessary to mention all days. It is allowed to eliminate any of days.Task. It is known that the rating was counted for d days in total. Write an algorithmto find such a longest list of days in chronological order, that popularity ratingswould only grow or at least would remain the same.If several solutions are possible, it is enough to find any one of them.Input. The first row of the input file contains the number of days d (3 ≤ d ≤ 15000).In the following d lines there are written ratings of corresponding days: rating ofthe first day is written to the first line, rating of the second day is written to thesecond one, etc. Rating is integer from the interval [-100; 100].11

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

Saved successfully!

Ooh no, something went wrong!