Inspections
Time limit2sMemory limit1024 MB
Given m tasks that each run a range of n machines in order, count the inspections needed for each safety value s in a list.
- Level
Hard8 of 10
- Topics
- Intervals, Sorting, Binary search, Implementation
- Solved
- No attempts yet
Problem
Benson the Rabbit now has to build a plane!
Benson the Rabbit runs a factory with machines numbered from 1 to . Each machine runs for one day, and only one machine can run at a time. Benson has tasks numbered from 1 to . Task is given by two positive integers and , where .
To complete task , Benson must run machines in that order. When a machine finishes, the next machine starts immediately. When task is complete, Benson immediately starts task , and so on until task is complete.
To follow safety regulations, the factory has a safety value . If a machine has not been run in the past or more days, it must be inspected before it can run. A machine does not need to be inspected the first time it is run.
Benson has candidate safety values . For each , compute the number of inspections needed if the safety value is .
Input
The first line contains three space-separated integers , , and . The next lines each contain two space-separated integers and , describing task . The last line contains space-separated integers .
Output
Output one line with space-separated integers. The -th integer is the number of inspections needed when the safety value is .