Hiring Employees
Time limit1sMemory limit256 MB
Given the daily minimum headcount and employee types that each work a range of consecutive days at a fixed cost, find the cheapest hiring plan that covers every day.
- Level
Medium7 of 10
- Topics
- Shortest path, Intervals, Graph
- Solved
- No attempts yet
Problem
After the successful Olympic bid, BuBu worked his way up to head of the human resources department at a subsidiary of the Olympic committee. On his first day, he faced a hard problem: hire a group of short-term employees for a new Olympic project. A rough estimate shows the project takes days, and on day it needs at least employees.
A total of employee types are available for hire. Type employees work from day to day , and each costs dollars. BuBu wants enough employees on every day at the lowest possible total cost. Help him find the optimal hiring plan. There is no limit on how many employees of each type can be hired.
Input
The first line contains two integers and .
The second line contains nonnegative integers, .
Each of the next lines contains three integers , , and , describing one employee type.
Output
Print a single line containing one integer, the cost of the optimal hiring plan.
Constraints
All other values in the input do not exceed .