Dynamic Program to solve an NP-complete partitioning problem
Let $\sigma(S)$ denote the sum of all the elements in $S$ and $A_i = \{a_1, \dots, a_i\}$.

Given, $i=0,\dots,n$ and $w \in \mathbb{Z}$, 
define $OPT[i,w]$ as the mazimum cardinality of a subset $S \cup S' \subseteq A_i$ where $S \cap S' = \emptyset$
and $\sigma(S) - 2\sigma(S') = w$.
If no possible choice for $S$ and $S'$ exists, then let $OPT[i,w]=-\infty$.

According to the above definition:
$$
OPT[0, w] = 
\begin{cases}
0 &amp; \text{if } w=0 \\
-\infty &amp; \text{if } w \neq 0 \\
\end{cases}
$$ 

For $i&gt;0$:
$$
    OPT[i, w] = \max\{ OPT[i-1, w], 1 + OPT[i-1, w-a_i], 1+ OPT[i-1, w+2a_i] \}.
$$

The answer to your problem is true iff $OPT[n, 0] &gt; 0$.
Each $OPT[i, w]$ can be computed in constant time (if you have already computed the values of $OPT[i-1, \cdot]$).
Moreover, there are only $O(n)$ possible choices for $i$ and $O(t)$ sensible choices for $w$, where $t = \sum_{i=1}^n a_i$.
This gives you a dynamic programming algorithm with time complexity $O(n t)$ and space complexity $O(t)$.