(简单) 搜索 HOJ 1044 Transportation
来源:互联网 发布:网络购票岫岩到沈阳 编辑:程序博客网 时间:2024/06/05 08:49
Transportation
Submitted : 269, Accepted : 148
Ruratania is just entering capitalism and is establishing new enterprising activities in many fields in- cluding transport. The transportation company TransRuratania is starting a new express train from city A to city B with several stops in the stations on the way. The stations are successively numbered, city A station has number 0, city B station number m. The company runs an experiment in order to improve passenger transportation capacity and thus to increase its earnings. The train has a maximum capacity n passengers. The price of the train ticket is equal to the number of stops (stations) between the starting station and the destination station (including the destination station). Before the train starts its route from the city A, ticket orders are collected from all onroute stations. The ticket order from the station S means all reservations of tickets from S to a fixed destination station. In case the company cannot accept all orders because of the passenger capacity limitations, its rejection policy is that it either completely accept or completely reject single orders from single stations.
Write a program which for the given list of orders from single stations on the way from A to B determines the biggest possible total earning of the TransRuratania company. The earning from one accepted order is the product of the number of passengers included in the order and the price of their train tickets. The total earning is the sum of the earnings from all accepted orders.
Input
The input is divided into blocks. The first line in each block contains three integers: passenger capacity n of the train (n > 0), the number of the city B station, and the number of ticket orders from all stations. The next lines contain the ticket orders. Each ticket order consists of three integers: starting station, destination station, number of passengers. In one block there can be a maximum of 22 orders. The number of the city B station will be at most 7. The block where all three numbers in the first line are equal to zero denotes the end of the input.Output
The output file consists of lines corresponding to the blocks of the input file except the terminating block. Each such line contains the biggest possible total earning.Example
Input file:10 3 40 2 11 3 51 2 72 3 1010 5 43 5 102 4 90 2 52 5 80 0 0Output file:
1934
- (简单) 搜索 HOJ 1044 Transportation
- (简单)搜索 HOJ 1022 Spacecraft Malfunction
- (简单)搜索 HOJ 1030 Labyrinth
- (简单) 搜索 HOJ 1048 Cipher
- (简单)搜索 HOJ 1070 Word
- (简单)搜索 HOJ 1075 The Castle
- (简单) 搜索 HOJ 1066 Substrings
- (简单) 搜索 HOJ 1097 Robot
- HOJ 1653 Heavy Transportation
- (简单)搜索 HOJ 1692 Choose Your Own Adventure
- hdu 4158 hoj 2581 Go 简单搜索
- poj1111 hoj 1639 Image Perimeters 简单搜索
- Go hdu 4158 hoj 简单搜索
- (简单) 搜索 HOJ 1085 Finding Rectangles
- (简单) 搜索 HOJ 1105 Egyptian Multiplication
- 搜索(IDA*)HOJ The Rotation Game
- 搜索(bfs) HOJ 1448 Dungeon Master
- 搜索(水) HOJ 1870 Race
- (概念题)线段树 HOJ 1495 Area of Simple Polygons
- (概念题)线段树 HOJ 1860 Mars Maps
- (简单)线段树 HOJ 2965 Magic-Pen4
- (简单)搜索 HOJ 1022 Spacecraft Malfunction
- (简单)搜索 HOJ 1030 Labyrinth
- (简单) 搜索 HOJ 1044 Transportation
- (简单) 搜索 HOJ 1048 Cipher
- textview 使用自己的字体
- (中等) 搜索 HOJ 1049 sticks
- (简单) 搜索 HOJ 1066 Substrings
- (简单)搜索 HOJ 1070 Word
- (简单)搜索 HOJ 1075 The Castle
- (简单) 搜索 HOJ 1085 Finding Rectangles
- (简单) 搜索 HOJ 1097 Robot
程序博客网,程序员的互联网技术博客家园。csdn论坛精品 msdn技术资料都在这里