In the event of technical difficulties with Szkopuł, please contact us via email at email@example.com.
If you are familiar with IRC chat, the support team is also reachable on PIRC network (
#szkopul channel. If you are not, just use email.
Please do not ask us things like "how to solve task XYZ?".
Please remember that the support team has to sleep sometimes or go to work in real life.
The streets of Byte City form a regular, chessboardlike network - they are either north-south or west-east directed. We shall call them NS- and WE-streets. Furthermore, each street crosses the whole city. Every NS-street intersects every WE- one and vice versa. The NS-streets are numbered from to , starting from the westernmost. The WE-streets are numbered from to , beginning with the southernmost. Each intersection of the 'th NS-street with the 'th WE-street is denoted by a pair of numbers (for , ).
There is a bus line in Byte City, with intersections serving as bus stops. The bus begins its itinerary by the intersection, and finishes by the intersection. Moreover, the bus may only travel in the eastern and/or northern direction.
There are passengers awaiting the bus by some of the intersections. The bus driver wants to choose his route in a way that allows him to take as many of them as possible. (We shall make an assumption that the interior of the bus is spacious enough to take all of the awaiting passengers, regardless of the route chosen.)
Write a programme which:
The first line of the standard input contains three positive integers , and - denoting the number of NS-streets, the number of WE-streets and the number of intersections by which the passengers await the bus, respectively (, , ).
The following lines describe the deployment of passengers awaiting the bus, a single line per intersection. In the 'st line there are three positive integers , and , separated by single spaces, , , . A triplet of this form signifies that by the intersection passengers await the bus. Each intersection is described in the input data once at the most. The total number of passengers waiting for the bus does not exceed .
Your programme should write to the standard output one line containing a single integer - the greatest number of passengers the bus can take.
For the input data:
8 7 11 4 3 4 6 2 4 2 3 2 5 6 1 2 5 2 1 5 5 2 1 1 3 1 1 7 7 1 7 4 2 8 6 2
the correct result is:
Task author: Wojciech Rytter.