clothes
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Description
jiangys is going hiking and needs to pack some clothes.
He has clothes, and the -th one keeps him warm by points. He can choose to bring clothes to meet the weather for the next days.
Each day has different rules:
If , the total warmth of the clothes he wears that day must be at least .
If , the total warmth must not exceed .
Each day, he can pick some of the clothes he packed(but must wear, so at least one).
What's the smallest number of clothes he needs to bring to meet all day's rules? If it's impossible, output .
Input Format
First line: , number of clothes.
Second line: , warmth of each clothes.
Third line: , number of days.
Next lines: and , rules for each day.
$1 \leq n \leq 3 , 1 \leq a_i \leq 2 \times 10^5, 1 \leq m \leq 100, 1 \leq t_i \leq 2,1 \leq x_i \leq 10^9$.
Output Format
The smallest number of clothes he needs to bring, or if impossible.
Sample Input #1
3
2 3 5
1
1 10
Sample Output #1
3
Sample Input #2
3
2 3 5
2
1 5
2 2
Sample Output #2
2
Sample Input #3
3
7 11 13
2
1 24
2 7
Sample Output #3
3
Sample Input #4
2
17 19
2
1 16
2 18
Sample Output #4
1
Sample Input #5
3
2 11 19
2
1 1000000000
2 1
Sample Output #4
-1
2025XCPC集训队&&算法培训 — 综合训练(一)
- 状态
- 已结束
- 规则
- ACM/ICPC
- 题目
- 5
- 开始于
- 2025-8-22 19:00
- 结束于
- 2025-8-22 22:00
- 持续时间
- 3 小时
- 主持人
- 参赛人数
- 21