#K77832. Process Customer Requests

    ID: 34952 Type: Default 1000ms 256MiB

Process Customer Requests

Process Customer Requests

You are given \(B\) branches, where the \(i\)-th branch has a certain number of cars available. Next, there are \(C\) customer requests. Each customer request is represented by three integers: the branch number, the number of cars requested, and a duration. For each request, if the corresponding branch has at least the requested number of cars, serve the customer by deducting the requested number of cars from that branch. Otherwise, the request is ignored.

Your task is to determine how many customer requests are successfully served.

Note: The duration value in each request does not affect the processing of the request.

inputFormat

The input is read from standard input and has the following format:

  1. An integer \(B\) representing the number of branches.
  2. A line with \(B\) space-separated integers \(a_1, a_2, \dots, a_B\), where \(a_i\) is the number of cars available at branch \(i\).
  3. An integer \(C\) representing the number of customer requests.
  4. Then \(C\) lines follow, each line containing three integers: the branch number, the number of cars requested, and the duration.

outputFormat

Output a single integer to standard output representing the number of customer requests that were successfully served.

## sample
5
10 5 8 2 1
4
1 3 2
2 6 1
3 2 3
5 1 1
3