编程大赛-3

 

Problem 7: che

 



CHE


 

There is some money put on some squares of a large rectangular chessboard. You must find how much money you can pick up while going from upper left corner (first row and first column) to the right lower corner. You can move right and/or down only.

 

Input: (standard input)

+Line 1 contains three space-separated integers: number of rows – r, and columns - c of a chessboard, where 1 <= r, c <= 10000, and the number of squares – m, where money is stored: 1 <= m <= 50000.

+Line i + 1, (for 1 <= i <=  m) contains three space-separated integers ri,  cimi. The first two  are coordinates of a particular square where the money is stored, i.e.: ri - row number,  ci - column number,  mi – amount of money put on this square where: 1 <= ri <=  r, 1 <= ci  <=  c, 1 <=  mi <= 10000

           

 

Output: (standard output)

Your program should write the maximum amount of money you can get.

 

Example:

For sample input:

3 4 6

1 1 4

2 2 4

1 3 2

3 1 3

3 2 1

2 3 2

 

A correct output format:

10

 


Problem 8: pal



PAL


 

A word is called to be a palindrome if it reads the same backward or forward. So "abaaba" is a palindrome while "abaxba" is not.  For a given word, find out how many letters must be inserted into the word to make it a palindrome. A word consists of letters: a..z.

 

Input: (standard input)

+Line 1 contains one word no longer that 2000 letters.

 

Output: (standard output)

Your program should write the smallest number of letters, which must be inserted into the word to turn the word into a palindrome.

 

Example:

For sample input:

ilovepoland

 

a correct output format:

6

 

Problem 9: emm



EMM


 

AnyPath complex generates n EMM events during a single session. All of them are handled later by EMM server. Each event gets its ID number which indicates the order in which it was created. The first event ID equals 1 and so on till n. The server creates a thread to handle the single EMM event. Threads work at different priorities and notify the server when they are done. Because of mutexes no two threads end at exactly the same time. When all threads are done, for each consecutive EMM event starting from the first one (with ID = 1), the server outputs how many later EMM events (with higher ID) have been handled earlier. Having the server output, write a program to find out the order of IDs in which events were handled.

 

Input: (standard input consists of 2 lines)

+Line 1 contains a number of EMM events n, 0 < n < 100 000,

+Line 2 contains space separated numbers, and i-th number indicates how many events with a greater ID were handled earlier than an event with ID = i.

 

Output: (standard output)

Your program should print out in one line the correct order of IDs in which events were handled.

 

Example:

For sample input:

4

2 1 1 0 

 

a correct output format:

4 2 1 3

posted @ 2015-09-24 14:48  forwardslash  阅读(80)  评论(0)    收藏  举报