Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Gourmet Grazers
Description Like so many others, the cows have developed very haughty tastes and will no longer graze on just any grass. Instead, Farmer John must purchase gourmet organic grass at the Green Grass Grocers store for each of his Each cow A ≤ 1,000,000,000) and with a greenness score at least _{i}B (1 ≤ _{i}B ≤ 1,000,000,000). The GGG store has _{i}M (1 ≤ M ≤ 100,000) different types of grass available, each with a price C (1 ≤ _{i}C ≤ 1,000,000,000) and a greenness score of _{i}D (1 ≤ _{i}D ≤ 1,000,000,000). Of course, no cow would sacrifice her individuality, so no two cows can have the same kind of grass._{i}Help Farmer John satisfy the cows' expensive gourmet tastes while spending as little money as is necessary. Input * Line 1: Two space-separated integers: B _{i}* Lines N+2..N+M+1: Line i+N+1 contains two space-separated integers: C and _{i}D _{i}Output * Line 1: A single integer which is the minimum cost to satisfy all the cows. If that is not possible, output -1. Sample Input 4 7 1 1 2 3 1 4 4 2 3 2 2 1 4 3 5 2 5 4 2 6 4 4 Sample Output 12 Source |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator