Xiao Ming is going hiking and needs to pack some clothes.
He has $$$n$$$ clothes, and the $$$i$$$-th one keeps him warm by $$$a_i$$$ points. He can choose to bring $$$1 \sim n$$$ clothes to meet the weather for the next $$$m$$$ days.
Each day has different rules:
If $$$t_i=1$$$, the total warmth of the clothes he wears that day must be at least $$$x_i$$$.
If $$$t_i=2$$$, the total warmth must not exceed $$$x_i$$$.
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 days' rules? If it's impossible, output $$$-1$$$.
First line: $$$n$$$, number of clothes.
Second line: $$$a_1 \sim a_n$$$, warmth of each clothes.
Third line: $$$m$$$, number of days.
Next $$$m$$$ lines: $$$t_i$$$ and $$$x_i$$$, rules for each day.
$$$1 \le n \le 3$$$, $$$1 \le a_i \le 2 \times 10^5$$$, $$$1 \le m \le 100$$$, $$$1 \le t_i \le 2$$$, $$$1 \le x_i \le 10^9$$$.
The smallest number of clothes he needs to bring , or $$$-1$$$ if impossible.
32 3 511 10
3
32 3 521 52 2
2
37 11 1321 242 7
3
| Name |
|---|


