Design Problemset
题号:NC211817
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

In xCPC contest, there are totally types of problems. Now you have a_i problems in type , and you want to make some problemsets with these problems.

In your opinion, the number of problems in one problemset must be in interval , and the number of problems in type must be in interval .

Now you want to know the maximum number of problemsets you can make, where one problem can be used in no more than one problemset.

输入描述:

The first line contains three integers .

The second line contains integers .

Following lines each contains two integers .

输出描述:

Only one line containing one integer, denoting the maximum number of problemsets you can make.
示例1

输入

复制
4 10 12
4 20 10 6
1 2
3 5
2 4
0 2

输出

复制
4

说明

One possible scheme is (1, 5, 2, 2), (1, 5, 2, 2), (1, 5, 3, 1), (1, 5, 3, 1)_{}.