#C8954. Remaining People in Queue
Remaining People in Queue
Remaining People in Queue
You are given a queue of n people. Each person has a certain patience level, represented by an integer. There are also m time slots during which a service is provided. At each time slot:
- The current time moves forward to the slot time.
- For every minute that passes until this slot, each person in the queue loses 1 unit of patience. A person leaves the queue if their patience drops to 0 or below.
- If there is still someone in the queue exactly at the opening of the slot, the person at the front is served and removed from the queue.
Formally, if a person with patience p waits for t minutes, they will leave if \(p - t \le 0\). Your task is to determine the number of people remaining in the queue after all slot openings have been processed.
inputFormat
The input is given via stdin and consists of:
- An integer n representing the number of people in the queue.
- A line containing n space-separated integers representing the patience levels of these people.
- An integer m representing the number of time slots.
- A line containing m space-separated integers indicating the times at which the slots open.
outputFormat
Output a single integer to stdout — the number of people remaining in the queue after all time slots have been processed.
## sample4
5 3 6 2
5
1 2 4 5 6
0