Yes, we shall use dynamic programming and extend our subset-sum algorithm here.
- Let $R(i, \ s, \ t)$ be true iff there exists a subset $K \in \{1, ...
i\}$ such that $$\sum_{i \in K} a_i = s \quad and \quad\sum_{i \in K} b_i = t.$$
Which subproblem would then give us the result we need? $R(n, 0, 0)$!
Now, let's find a recursive relation for our subproblem in terms of smaller subproblems:
$$R(i, \ s, \ t) := [(a_i==s) \wedge (b_i==t)] \\\vee R(i-1, \ s, \ t)\\\vee\ R(i-1, \ s-a_i, \ t-b_i) $$
where, $\vee$ is the OR operator and $\wedge$ is the AND operator.
This relation works on the inclusion-exclusion principle - either we include the $i$th index in our subset $K$ or not. But the caveat here is that if we include the $i$th index, we must include both $a_i$ and $b_i$.
- If we do not include the $i$th index, $R(i, \ s, \ t)$ reduces simply
to $R(i-1, \ s, \ t).$
- If we do include the $i$th index, either ($a_i$ should be $s$) AND ($b_i$ should be t). Or, we must have some common subset of the two sets summing to $s-a_i$ and $t-b_i$ respectively i.e. $R(i-1, \ s-a_i, \ t-b_i)$ should be true.
For the sake of completeness, the base cases are $R(1, \ s, \ t) := (a_1 ==s) \wedge (b_1==t)$.
Edit:The runtime of the algorithm then is $O(n^3{B^2})$ (Why?), which is pseudo-polynomial too.