#P16198. [ROIR 2014 Day 2] Cond 空调
[ROIR 2014 Day 2] Cond 空调
Problem Description
In the “Smart Campus” project, it was decided to install a new-generation air conditioner in every classroom in the school for automatic cooling and ventilation. According to the design, each classroom can have only one air conditioner, and the air conditioner’s power must match the classroom size—the larger the classroom, the higher the required power.
The school’s classrooms are numbered consecutively from to . It is known that classroom needs an air conditioner with power at least watts.
The school administration provides different air conditioner models for purchase. Each model has a corresponding power and price. Please write a program to compute the minimum total cost to equip all classrooms with air conditioners.
Input Format
The first line contains an integer , the number of classrooms.
The second line contains integers , where is the minimum required power (in watts) for the air conditioner in classroom .
The third line contains an integer , the number of available air conditioner models.
The next lines each contain two integers and , where is the power (in watts) of model and is its price.
Output Format
Output one integer, the minimum total cost to equip all classrooms with air conditioners. It is guaranteed that there is at least one feasible solution that meets the requirements of all classrooms.
1
800
1
800 1000
1000
3
1 2 3
4
1 10
1 5
10 7
2 3
13
Hint
In the first sample, you can only buy the only available air conditioner, which costs yuan.
In the second sample, the optimal solution is to install model in classrooms and , and model in classroom , for a total cost of yuan ().
Scoring
For the -point testdata, .
Translation source: GPT 4.1 mini.
Translated by ChatGPT 5