Inspections | 프로그래밍의 벗 PivotOJ
PivotOJ

Inspections

시간 제한: 2000ms메모리 제한: 1024MB출처: NOI 2023BOJ 28496

문제

Benson the Rabbit now has to build a plane!

Benson the Rabbit has a factory with nn machines numbered from 11 to nn. Each machine runs for one day and only one machine can run at a time. He has mm tasks to complete, numbered from 11 to mm. Each task ii is represented by two positive integers l[i]l[i] and r[i]r[i] where l[i] ≤ r[i].

To complete task ii, Benson needs to run machines l[i],l[i]+1,,r[i]l[i], l[i] + 1, \dots , r[i] in that order. Once a machine has finished running, the next machine starts immediately. Once task ii is complete, Benson immediately starts task i+1i + 1 until task mm is complete.

In order to comply with safety regulations, the factory must have an safety value ss. If a machine with safety value ss was not run in the past ss or more days, this machine needs to be inspected before it can be run. Machines do not need to be inspected the first time they are run. See the samples for more details.

Benson has qq different candidate safety values s[1],s[2],,s[q]s[1], s[2], \dots , s[q]. For each safety value s[j]s[j], help him compute the number of inspections that need to be done if the safety value is s[j]s[j].

입력

The first line of input will contain 33 spaced integers nn, mm and qq, representing the number of machines, tasks and safety values respectively.

The next mm lines of input will contain 22 spaced integers each. The ii-th of these lines will contain l[i]l[i] and r[i]r[i] respectively, describing task ii.

The next line of input will contain qq spaced integers s[1],s[2],,s[q]s[1], s[2], \dots , s[q], which represent the qq safety values to be tested.

출력

Output one line with qq spaced integers, the jj-th integer representing the number of inspections that need to be done if the safety value is s[j]s[j].

예제

예제 1

입력
5 3 7
1 3
3 5
2 3
0 1 2 3 4 5 6
출력
3 2 2 2 1 0 0

예제 2

입력
6 6 7
1 6
1 5
1 4
1 3
1 2
1 1
1 2 3 4 5 6 7
출력
15 14 12 9 5 0 0
코드를 제출하려면 로그인하세요.