Advanced Subset Sum Queries
Given a set of
, you are asked to perform
qqueries. Each query is one of the two types:
- Type 1: Determine whether there exists a subset of numbers that sum up to
- Type 2: Remove the given number
sfrom the set.
The first line of the input contains a single integer
n(1 ≤ n ≤ 300), the size of the set of numbers. The second line contains
, the elements of the set.
The third line of the input contains a single integer
q, the number of queries. The next
qlines each contain two space-separated integers,
- For a Type 1 query, the first integer
tis 1 and the second integer
srepresents the target sum.
- For a Type 2 query, the first integer
tis 2 and the second integer
srepresents the element that should be removed.
The number of Type 2 queries does not exceed 200
For each Type 1 query, output
Yesif such a subset exists, otherwise output
4 1 2 5 7 7 1 4 1 3 1 10 2 1 1 10 1 3 1 9
No Yes Yes No No Yes
Time limit: 4 seconds
Memory limit: 512 MB
Output limit: 1 MB