SP8462 BARN - Barn Allocation

Description

```
```
Farmer John recently opened up a new barn and is now accepting stall
allocation requests from the cows since some of the stalls have a
better view of the pastures.

The barn comprises N (1 
                            

Input Format

```
```
* Line 1: Two space-separated integers: N and M

* Lines 2..N+1: Line i+1 contains a single integer: C_i

* Lines N+2..N+M+1: Line i+N+1 contains two integers: A_i and B_i
```
```
                            

Output Format

`
`* Line 1: The maximum number of requests that can be satisfied``