<<

arXiv:1912.12529v2 [cs.DS] 26 Oct 2020 ne h uoenUin oio 00rsac n innovat and research 2020 Horizon Unions European the under [email protected] [email protected] ∗ † ‡ hswr spr ftepoetTPAta a eevdfundi received has that TIPEA project the of part is work This aradUiest n a lnkIsiuefrInformati for Institute Planck Max and University Saarland aradUiest n a lnkIsiuefrInformati for Institute Planck Max and University Saarland from Partition h ito rbesta r qiaett Min-Plus-Convolution. to equivalent are that firs problems the of adds list This the scheme. approximation randomized subquadratic eaatorrdcinfrom reduction our adapt We h r sarnoie prxmto ceernigi time in running scheme approximation randomized a is art the ceefor scheme oe re mrvmnsfo i-lsCnouinto Min-Plus-Convolution from improvements order lower eedneon dependence opeiyter,teei oapoiainshm for scheme approximation no is con there theory, Min-Plus-Convolution complexity the assuming Thus, Min-Plus-Convolution. sta optn (1 a computing that is nfiegandcmlxt hoyadcnb ovdnieyi time in naively solved be can and theory complexity fine-grained in ahmtclotmzto.Tesaeo-h-r approximation state-of-the-art The optimization. mathematical ue (1 a putes npriua,a(1 a particular, In o h related the For eetbihacneto oMnPu-ovlto,apolmta so is that problem a Min-Plus-Convolution, to connection a establish We Approximating Partition − Partition unn ntime in running ε -prxmto ntime in )-approximation prxmtn ustSmadPartition and Sum Subset Approximating n oMnPu-ovlto.Ti ilsa mrvdapoiainschem approximation improved an yields This Min-Plus-Convolution. to n 1 and − Partition SubsetSum 1 /n − ieGandPrpcieon Perspective Fine-Grained A htbek h udai barrier. quadratic the breaks that /ε -prxmto a ecmue ntime in computed be can )-approximation 1 alBringmann Karl nteohrdrcin u euto losu otase known transfer to us allows reduction our direction, other the In . /n O e SubsetSum -prxmto for )-approximation ( n rbe,a motn pca aeof case special important an problem, +1 sacascadfnaetlpolmi optrsineand science computer in problem fundamental and classic a is /ε 3 O e / 2 (min .Oragrtmi h first the is algorithm Our ). oMnPu-ovlto ooti eae reduction related a obtain to Min-Plus-Convolution to Abstract { /,n n/ε, † 1 SubsetSum aieo Nakos Vasileios +1 o rgam gatareetN.850979). No. agreement (grant programme ion /ε SubsetSum 2 gfo h uoenRsac oni (ERC) Council Research European the from ng } s aradIfraisCmu,Germany. Campus, Informatics Saarland cs, s aradIfraisCmu,Germany, Campus, Informatics Saarland cs, Gn,Lve’8 elrre al.’97]. et Kellerer Levner’78, [Gens, ) SubsetSum ssbudaial qiaetto equivalent subquadratically is O e ( ceefor scheme n deterministic O prxmto rbe to problem approximation t 1 + ihsrnl subquadratic strongly with ‡ ( SubsetSum n etr rmfine-grained from jecture O /ε 2 hc ilsamildly a yields which , ( ). n 5 / 2 3 .Ormi result main Our ). atclrinterest particular f Mcae al.’19]. et [Mucha ) SubsetSum approximation ∗ h tt of state the , com- for e 1 Introduction

1.1 Approximating SubsetSum In the SubsetSum problem the task is to decide, given a set X of n positive integers and a target number t, whether some subset of X sums to t. This is a fundamental problem at the intersection of , mathematical optimization, and operations research. It belongs to Karp’s initial list of 21 NP-complete problems [37], is a cornerstone of algorithm design [41, 48], and a special case of many other problems like Knapsack or Integer Programming. Since the problem is NP-hard, it is natural and imperative to study approximation algorithms. To this end, consider the following classic optimization version of SubsetSum: Given a set X of n positive integers and a target t, compute the maximum sum among all subsets summing to at most t. Formally, the task is to compute OPT := max Σ(Y ) Y X, Σ(Y ) t , where Σ(Y ) { | ⊆ ≤ } denotes the sum of all elements of Y . This optimization version is still a special case of Knapsack and Integer Programming, and it naturally gives rise to the classic notion of an approximation scheme for SubsetSum: Given an instance (X,t) and a parameter ε> 0, compute a subset Y X ⊆ that satisfies (1 ε)OPT Σ(Y ) OPT. − ≤ ≤ In 1975 Ibarra and Kim [32] designed the first approximation scheme for SubsetSum, running in time (n/ε2). According to [41, Section 4.6], a similar algorithm was found by Karp [38]. Lawler O then presented an (n+1/ε4)-time algorithm [46]. These three algorithms in fact even work for the O more general Knapsack problem. For SubsetSum, Gens and Levner designed further improved algorithms running in time (n/ε) [27, 28] and in time (min n/ε, n+1/ε3 ) [30]. Finally, Kellerer O O { } et al. presented an approximation scheme running in time (min n/ε, n + 1/ε2 log(1/ε) ) [40, 42]. O { } This remains the state of the art for over 20 years. In particular, expressing the running time in the form ((n + 1/ε)c), the exponent c = 2 was achieved over 40 years ago [27, 28], but an exponent O c< 2 remains elusive. The starting point of this paper is, thus, the following question:

Does SubsetSum admit an approximation scheme in time ((n + 1/ε)2 δ ) for some δ > 0? O − Pseudopolynomial-time Algorithms. Observe that an approximation scheme with a setting of ε< 1/t solves SubsetSum exactly. For this reason, approximation algorithms are closely related to exact algorithms running in pseudopolynomial time. The classic pseudopolynomial time algorithm for SubsetSum is Bellman’s dynamic programming algorithm that runs in time (nt) [10]. This O running time was recently improved, first by Koiliaris and Xu to1 (min √n t,t4/3 ) [43], then O { · } further to a randomized (n + t) algorithm [12], see also [35] for further improvements in terms of O logfactors. The improved running time is optimal up to lower ordere factors; in particular there is no algorithm running in timee poly(n) t0.999 assuming the Strong Exponential Time Hypothesis [1] or the Set Cover Conjecture [23]. These developments for pseudopolynomial algorithm raise the hope that one can design better approximation schemes for SubsetSum, improving time (n/ε) to (n + 1/ε), analogously to O O the improvement from (nt) to (n + t). Such an improved running time of (n + 1/ε) would O O O then be optimal up to lower order factors, since the lower bound for pseudopolynomiale algorithms transfers to approximation schemes,e in particular SubsetSum has no approximatione scheme in time poly(n)/ε0.999, assuming the Strong Exponential Time Hypothesis or the Set Cover Conjecture. It seems difficult to prove a higher lower bound, thereby ruling out an improvement to time (n+1/ε). Indeed, so far all conditional lower bounds for approximations schemes for SubsetSum, O 1 Oe e By we hide factors of the form polylog(nM), where n is the number of input numbers and M is the largest input number.

2 Knapsack, and related problems used the connection to pseudopolynomial time algorithms [50]. Since SubsetSum is in pseudopolynomial time (n + t), this connection cannot prove any higher O lower bounds than n + 1/ε, up to lower order factors. e Min-Plus-Convolution. In this work we connect SubsetSum to the MinConv problem, in which we are given integer sequences A, B Zn and the goal is to compute the sequence C ∈ ∈ Z2n with C[k] = min A[i] + B[j]. The naive running time of (n2) can be improved to i+j=k O n2/2Ω(√log n) by a reduction to All Pairs Shortest Path [11] and using Williams’ algorithm for the latter [52]. Despite considerable attention [6, 7, 9, 11, 13, 15, 18, 24, 33, 44, 45], no (n2 δ)-time O − algorithm has been found, which was formalized as a hardness conjecture in fine-grained complexity theory [24, 44]. Many conditional lower bounds from the MinConv conjecture as well as several MinConv-equivalent problems are known, see, e.g., [7, 24, 33, 44, 45]. In particular, the Knapsack 2 δ problem with weight budget W can be solved in time ((n + W ) − ) for some δ > 0 if and only if ′ O MinConv can be solved in time (n2 δ ) for some δ > 0 [24, 44]. O − ′ Our Contribution to SubsetSum. We prove that computing a (1 1/n)-approximation for − SubsetSum is equivalent to the MinConv problem, thus adding the first approximation problem to the list of known MinConv-equivalent problems. This negatively answers our main question for SubsetSum approximation schemes running in strongly subquadratic time, conditional on the MinConv conjecture. Moreover, our reductions allow us to transfer the known lower order improvements from MinConv to approximating SubsetSum, which yields the first algorithmic improvement in over 20 years.

1.2 Approximating Partition The Partition problem is the special case of SubsetSum where we want to partition a given set X into two sets of the same sum, or, equivalently, solve SubsetSum with target t = Σ(X)/2. This problem arises in scheduling [36], minimization of circuit sizes and [49], as well as game theory [31]. While naturally all algorithms for SubsetSum also apply to the Partition problem, designing approximation algorithms specific to Partition also has a long history, see, e.g., [29]. From a lower bounds perspective, the state of the art for Partition is the same as for SubsetSum: by the same arguments as above we cannot expect an approximation scheme running in time poly(n)/ε0.999. However, from an upper bounds perspective the two problems differ significantly: For a long time the fastest approximation scheme for Partition was also quadratic, namely in time (min n/ε, n + 1/ε2 ) [29], but recently Mucha et al. [50] designed a O { } randomized approximation scheme with a strongly subquadratic running time of (n + 1/ε5/3). O e Our Contribution to Partition. Note that we separate SubsetSum and ePartition with respect to approximation, since for the former we prove a quadratic lower bound based on the MinConv conjecture, while the latter has a strongly subquadratic approximation scheme [50]. Furthermore, we design an improved approximation scheme for Partition that runs in time (n + 1/ε3/2), by extending our techniques that we develop for reducing SubsetSum to Min- O Conv. It is worth noting that our algorithm is deterministic, and thus it is the first deterministic approximatione scheme for Partition with subquadratic running time, answering a question in [50]. The unifying theme between our algorithmic results is a notion of sparse approximation, along with an efficient algorithm which takes as input sparse approximations of two sets, and computes a sparse approximation of their sumset by calling as black box a MinConv algorithm.

3 1.3 Formal Statement of Results Approximating SubsetSum. We prove a subquadratic equivalence of approximating Subset- Sum and MinConv, by designing two reductions as follows.

Theorem 1.1 (Reduction from SubsetSum to MinConv, Section 4). If MinConv can be solved in time T (n), then SubsetSum has a randomized approximation scheme that is correct with high probability2 and runs in time (n + T (1/ε)). O MinConv Our reduction even transferse the lower order improvements of the algorithm that runs in time n2/2Ω(√log n) [11, 52]. This yields the first improved approximation scheme for SubsetSum in over 20 years.

Corollary 1.2 (Approximation Scheme for SubsetSum). SubsetSum has a randomized approxi- mation scheme that is correct with high probability and runs in time

(1/ε)2 n + . O Ω(√log(1/ε))  2  The second reduction is as follows:e

Theorem 1.3 (Reduction from MinConv to SubsetSum, Section 3). If SubsetSum has an 2 δ approximation scheme running in time ((n + 1/ε) − ) for some δ > 0, then MinConv can be ′ O solved in time (n2 δ ) for some δ > 0. O − ′ Under the MinConv conjecture this rules out the existence of approximation schemes for 2 δ SubsetSum running in strongly subquadratic time ((n + 1/ε) − ) for any δ > 0. Taken together, O 2 δ the two reductions prove that SubsetSum has an approximation scheme in time ((n + 1/ε) − ) ′ O for some δ > 0 if and only if MinConv can be solved in time (n2 δ ) for some δ > 0. O − ′ Approximating Partition. We adapt our reduction from SubsetSum to MinConv for Par- tition and obtain the following reduction.

Theorem 1.4 (Reduction from Partition to MinConv, Section 5). If MinConv can be solved in time T (n), then Partition has a deterministic approximation scheme that runs in time

1 L n + min L T + . O 1 L 1/ε · Lε ε  ≤ ≤     e Even with the trivial (n2)-time algorithm for MinConv, for L := 1/ε1/2 this yields an im- O proved approximation scheme for Partition running in time (n + 1/ε3/2). Plugging in the best O known bound of n2/2Ω(√log n) for MinConv [11, 52], which has been derandomized in [19], yields the following. e

Corollary 1.5 (Approximation Scheme for Partition). Partition has a deterministic approxima- tion scheme that runs in time (1/ε)3/2 n + . O 2Ω(√log(1/ε)) ! c 2In this paper, “with high probability” meanse success probability 1−(ε/n) for a constant c> 0 that can be freely chosen by adapting the constants in the algorithm.

4 In comparison with the previously best approximation scheme by Mucha et al. [50], we improve the exponent of 1/ε from 5/3 to 3/2, and our algorithm is deterministic. Moreover, while their algorithm makes black-box usage of a relatively involved additive-combinatorics-based algorithm by Galil and Margalit [26], we obtain our results via elementary means, closer in spirit to the tra- ditional approaches for approximating SubsetSum. In fact, we obtain our approximation scheme for Partition by augmenting our reduction from SubsetSum to MinConv by addtional ideas specific to the Partition problem.

1.4 Technical Overview Reduction from MinConv to SubsetSum. In our lower bound for SubsetSum (Theorem 1.3), we start from the known reduction from MinConv to Knapsack [24, 44], and design a surpris- ingly simple reduction from (exact) Knapsack to approximating SubsetSum. In this reduction, we use the strict condition Σ(Y ) t in an interesting way, to simulate exact inequality checks on ≤ sums of very large numbers, despite being in an approximate setting. This allows us to embed the potentially very large values of Knapsack items into an instance of approximate SubsetSum.

Reduction from SubsetSum to MinConv. The other reduction is essentially an approxima- tion scheme for SubsetSum, using as black box an algorithm for MinConv with subquadratic running time TMinConv(n). It seems difficult to adapt the known approximation schemes [27, 28, 30, 40, 42] to make use of a MinConv algorithm, since they all in some way follow the same approach as Bellman’s pseu- dopolynomial algorithm: Writing X = x ,...,x , they compute an approximation of the set of { 1 n} all subset sums of x1,...,xi from an approximation of the set of all subset sums of x1,...,xi 1 , { } { − } for i = 1,...,n. To obtain total time (n/ε), each iteration must run in time (1/ε), so there is O O no point at which a subquadratic algorithm for MinConv seems useful. (The (n + 1/ε2)-time O approximation schemes follow the samee iteration, but start with a preprocessinge step that removes all but (1/ε) items.) e O In contrast, the recent pseudopolynomial algorithms for SubsetSum [12, 35, 43] use convolution methods,e so in principle their structure allows to plug in a MinConv algorithm. Moreover, the running time (n + t) [12, 35] suggests to replace standard convolution in time (t) by MinConv O O in time TMinConv(1/ε), to obtain the desired running time of (n + TMinConv(1/ε)). However, all O previous algorithmse along this line of research heavily assume an exact setting, specificallye that we have computed exact solutions to subproblems. e Here, we bring these two approaches together, by using ideas from the known approximation schemes to define the right notion of approximation, and then following the high-level structure of the pseudopolynomial algorithms with adaptations for our notion of approximation. In our notion of approximation, we say that a set A approximates a set B if A B and for any ⊆ b B there are lower and upper approximations a , a+ A with a b a+ a + εt. To avoid ∈ − ∈ − ≤ ≤ ≤ − having to solve SubsetSum exactly, we need to relax this notion further, by allowing a+ to take the value t + 1, for details see Definition 4.1. We establish that this notion satisfies several natural properties, e.g., it is transitive and behaves nicely under unions and sumsets. The connection to MinConv is then as follows. The main subroutine used by the recent pseudopolynomial algorithms is sumset computation: Given A, B N, compute A + B = a + b ⊆ { | a A, b B . Since the output-size of sumset computation can be quadratic in the input-size, ∈ ∈ } here we relax the goal and design a subroutine for approximate sumset computation, computing a set R that approximates A + B. To implement this subroutine, we first define a rasterization of A

5 and B as vectors A′,B′ with

A′[i] := min A [iεt/2, (i + 1)εt/2] B′[j] := min B [jεt/2, (j + 1)εt/2] . ∩ ∩   We then compute the vector C′ as the MinConv of A′ and B′, that is,

C′[k]= min A′[i]+ B′[j]. i+j=k

Note that we used the operation min at three positions in the above equations. By replacing 3 some of them by max, we obtain 2 = 8 similar expressions, giving rise to vectors C1′ ,...,C8′ . We show that the set of all entries of C1′ ,...,C8′ approximates A + B according to our notion of approximation. Since all involved vectors have length (1/ε), we can approximate sumsets in time O (TMinConv(1/ε)). O Finally, we use this approximate sumset computation as a subroutine and follow (a simplified variant of) the pseudopolynomial algorithm from [12]. The pseudocode is not changed much com- pared to [12], but the correctness proofs are significantly more complicated due to our approximate setting.

Approximating Partition. Here we describe our improved approximation scheme for Parti- tion, which follows from augmenting our reduction from SubsetSum to MinConv. Recall that Partition is the same as SubsetSum on target t = Σ(X)/2, and for simplicity let us assume OPT = t. Previous approximation schemes for this problem made the following observations. First, although the goal is to find a subset Y X with (1 ε)t Σ(Y ) t, it ⊆ − ≤ ≤ suffices to relax the goal to a weak approximation with (1 ε)t Σ(Y ) (1 + ε)t. Indeed, if t< − ≤ ≤ Σ(Y ) (1+ ε)t, then its complement X Y satisfies the desired guarantee (1 ε)t Σ(X Y ) t; ≤ \ − ≤ \ ≤ this heavily uses that for Partition we have t = Σ(X)/2. Second, because we can relax to this weak, two-sided approximation guarantee, we may round the input numbers. Specifically, if we focus on subsets Y X of small cardinality Y L, then rounding every number x X to x L ⊆ | |≤ ∈ · εt and solving SubsetSum in the rounded instance suffices for obtaining the weak approximation   guarantee. The approximation scheme by Mucha et al. [50] uses these observations by splitting X into large and small numbers. Any solution can only contain few large numbers, so in this part they can focus on subsets of small cardinality, which allows them to use the above rounding procedure and to solve the rounded instance by the pseudopolynomial algorithm [12]. For the small numbers, they exploit the solution structure of the instance by invoking a relatively involved additive-combinatorics-based algorithm by Galil and Margalit [26]. We avoid this dichotomy, and instead use the following observation: If we have sets Z1,Z2,...,ZL such that (Z + Z + . . . + Z ) [t] approximates (X; t) well, then we can again perform rounding 1 2 L ∩ S as before. Specifically, by rounding every x L Z to x L and solving the problem on the ∈ i=1 i · εt rounded instance, we obtain a value (and the corresponding set) that additively approximates OPT S   up to εt in a weak sense. The running time is controlled by the number L of sets Z , as well as the ± i time to solve the rounded instance. Note, however, that the rounded instance is not a SubsetSum instance as it was in [50] (because Zi may not be a two-element set), and hence it cannot be solved by a black-box invocation of [12]. However, it can still be solved using the standard exact sumset computation via Fast Fourier Transform in a tree-like fashion; the running time then depends on the structure of the sets Zi; in particular on the sizes of the intermediate sumsets. In our approximation scheme for Partition we use this observation to augment our algorithm for SubsetSum. Specifically, in our approximation scheme for SubsetSum we build a recursion

6 tree where level ℓ corresponds to 2ℓ many approximate sumset computations of sets with a sparse approximation of size 1/(2ℓε). Since our algorithm for approximate sumset computation requires essentially quadratic time, each recursive call on level ℓ takes time (1/(2ℓε)2), which over all 2ℓ O recursive calls on level ℓ gives time (1/(2ℓε2)). On the lower levels of this recursion tree, where ℓ O is large, this running time is low. On the upper levels, where ℓ is small,e we are left with the task of combining L = 2ℓ subproblems. Thise is exactly the setting (Z + . . . + Z ) [t] as discussed above. 1 L ∩ Hence, we replace the upper levels of the recursion tree by rounding and exact sumset computation. By balancing the lower and upper part, we obtain an approximation scheme for Partition running in time (n + 1/ε3/2). O 1.5 Relatede Work Our reduction from MinConv to approximating SubsetSum follows a recent trend in fine-grained complexity theory to show hardness of approximation. The first such result was presented by Abboud et al. [2], who proved a PCP-like theorem for problems in P and obtained hardness of ap- proximation for Orthogonal Vectors. Their results were extended to an equivalence and improved quantitatively (see, e.g., [20–22]) and generalized to parameterized complexity (see, e.g., [16, 39]). A similar approach was used on All Pairs Shortest Path [13]. While this line of research developed techniques to prove conditional lower bounds for constant-factor approximation algorithms (and higher approximation ratios), in this paper we obtain a conditional lower bound for an approxima- tion scheme, which does not already follow from a lower bound for a constant-factor approximation. Approximations schemes for the related Knapsack problem have also been widely studied, see, e.g., [17, 29, 32, 34, 41, 46]. For Knapsack, the state-of-the-art approximation scheme runs in time (n + 1/ε9/4) [34], see also [17]. A lower bound of (n + 1/ε)2 o(1) holds assuming the O − MinConv conjecture [50]; our conditional lower bound in this paper can be seen as an extension of this resulte to SubsetSum. Note that our SubsetSum result in this paper yields the first matching upper and lower bounds for approximation schemes for one of the classic Knapsack-type problems Partition, SubsetSum, and Knapsack. In this paper we consider variants of approximate SubsetSum that keep the strict constraint Σ(Y ) t intact. Mucha et al. [50] introduced a weaker variant of approximating SubsetSum, ≤ where they also relax this constraint from Σ(Y ) t to Σ(Y ) (1 + ε)t. They showed that such a ≤ ≤ weak approximation is closely connected to approximating Partition, and they obtain the same running time (n + 1/ε5/3) for both tasks. This shows that the strict upper bound Σ(Y ) t is O ≤ crucial for our results. Indeed, their algorithm and our conditional lower bound separate their weak notion of approximatione from the classic variant of approximation studied in this paper. It seems that it is possible to extend our approximation scheme for Partition to a weak approximation for SubsetSum, at the cost of making it randomized. We leave it as an open problem to find a deterministic weak approximation scheme for SubsetSum running in time (n + 1/ε3/2). O Further related work on the SubsetSum problem designs pseudopolynomial time algorithms for ModularSubsetSum [5], tackles the problem whether all attainable subsete sums smaller than t can be efficiently listed in outputsensitive time [14], and considers many more directions, see, e.g., [3, 4, 8, 14, 25, 47, 51].

2 Preliminaries

We write N = 0, 1, 2,... . For t N we let [t] = 0, 1,...,t . For sets A, B N we define their { } ∈ { } ⊆ sumset as A + B = a + b a A, b B and their capped sumset as A + B = (A + B) [t]. { | ∈ ∈ } t ∩

7 We use Σ(Y ) as shorthand notation for y Y y, and we denote the set of all subset sums of X below t by (X; t) := Σ(Y ) Y X, Σ(Y ) ∈ t . Furthermore, we denote (X) := (X; )= S { | ⊆ P≤ } S S ∞ Σ(Y ) Y X . { | ⊆ } Recall that in MinConv we are given integer sequences A = (A[0],...,A[n 1]) and B = − (B[0],...,B[n 1]) and the goal is to compute the sequence C = (C[0],...,C[2n 1]) with C[k]= − − min A[i]+ B[j], where the minimum ranges over all pairs (i, j) with 0 i,j

3 Lower Bound for SubsetSum

We now present our reduction from MinConv to approximating SubsetSum, proving Theorem 1.3. In this section we consider the following formulation of approximate SubsetSum:

GapSubsetSum: Given X,t and ε> 0, distinguish whether OPT = t or OPT < (1 ε)t. − If OPT [(1 ε)t,t) the output can be arbitrary. ∈ − Note that any approximation scheme for SubsetSum would be able to solve the above gap problem. By using this formulation as a gap problem, our reduction is general enough to cover a wide variety of specific problem formulations, as discussed in Section A. Our reduction from MinConv to GapSubsetSum goes via the Knapsack problem: Given n items with weights w1, . . . , wn and values v1, . . . , vn, and given a weight budget W and a value goal V , decide whether for some S [n] we have w W and v V . We again denote ⊆ i S i ≤ i S i ≥ by M the largest input number, that is w , v , W, V ∈ 1,...,M . ∈ i i P ∈ { } P Bellman’s classic dynamic programming algorithm solves Knapsack in time (nW ) [10]. In the O regime W n, this running time is (n2) and any improvement to time (n2 ε) would violate the ≈ O O − MinConv conjecture, as was shown independently by Cygan et al. [24, Theorem 2] and K¨unnemann et al. [44, Theorem 4.8]. Specifically, both references contain the followinge reduction.

Theorem 3.1. If Knapsack can be solved in time T (n,W ), then MinConv can be solved in time (T (√n, √n) n). O · Knapsack GapSubsetSum e We next show a simple reduction from (exact) to . Theorem 3.2. If GapSubsetSum can be solved in time T (n, 1/ε), then Knapsack can be solved in time (T (n,W )+ W ). O In combination with Theorem 3.1, we obtain that if GapSubsetSum can be solved in time e 2 δ ((n + 1/ε)2 δ ) for some δ > 0, then MinConv can be solved in time (√n − n)= (n2 δ/2). O − O · O − This proves Theorem 1.3. e e e Proof. Given a Knapsack instance, if n log M then we run Bellman’s algorithm to solve the ≤ instance in time (nW )= (W log M)= (W ). Therefore, from now on we assume n log M. O O O ≥ e 8 We construct an intermediate Knapsack instance by adding items of weight 2i and value 0 for each 0 i log(W ), and adding items of weight 0 and value 2i for each 0 i log(V ). Since ≤ ≤ − ≤ ≤ items of value less than or equal to 0 can be ignored, these additional items do not change whether the Knapsack instance has a solution. However, in case there is a solution, we can use these additional items to fill up the total weight to exactly W and decrease the total value to exactly V . In other words, if the Knapsack instance has a solution, then it also has a solution of total weight W and total value V . This increases the number of items by an additional (log M)= (n), since O O as discussed above we can assume n log M. As this is only an increase by a constant factor, with ≥ slight abuse of notation we still use n to denote the number of items, and we denote the weights and values of the resulting items by w1, . . . , wn and v1, . . . , vn, respectively. We note that negative values are only used in the intermediate Knapsack instance, and that all weights and values are still bounded by M, now in absolute value. The constructed SubsetSum instance does not contain any negative numbers, as can be checked from the following construction. We set M := 4nM and let X consist of the numbers x := w M v for 1 i n. For ′ i i · ′ − i ≤ ≤ t := W M V and ε := 1/(2W ) we construct the GapSubsetSum instance (X,t,ε). · ′ − To argue correctness of this reduction, first suppose that the Knapsack instance has a solution. Using the added items, there is a set S [n] such that w = W and v = V . The ⊆ i S i i S i corresponding subset x i S X thus sums to W M ∈ V = t. Hence, if∈ the Knapsack { i | ∈ } ⊆ · P ′ − P instance has a solution, then the constructed SubsetSum instance satisfies OPT = t. For the other direction, suppose that the Knapsack instance has no solution, and consider any set S [n]. Then we are in one of the following three cases: ⊆ • Case 1: w W + 1. Then we have x (W + 1)M v . Since v i S i ≥ i S i ≥ ′ − i S i i S i ≤ nM = M /4∈ we obtain x > W M >t. Hence,∈ S does not correspond∈ to a feasible solution∈ P′ i S i ′ P P P of the constructed SubsetSum∈ instance. P • Knapsack Case 2: i S wi = W . Since the instance has no solution, we have i S vi < V . This yields ∈ x = W M v > W M V = t. Hence, S does not correspond∈ to a P i S i ′ − i S i ′ − P feasible solution∈ of the constructed∈SubsetSum instance. P P • Case 3: w W 1. Then we have x (W 1)M v . Since v i S i ≤ − i S i ≤ − ′ − i S i | i S i|≤ nM = M /4,∈ we obtain x W M 0∈.75M . Using V M ∈M /4 yields ∈ x P′ i S i ≤ ′ −P ′ ≤ P≤ ′ P i S i ≤ W M V 0.5M . Finally,∈ since 0.5M = εW M > ε(W M V ), we obtain ∈ x < ′ − − ′ P ′ ′ ′ − Pi S i (1 ε)(W M V ) = (1 ε)t. ∈ − ′ − − P From this case distinction we obtain that any subset Y X is either infeasible, i.e., Σ(Y ) >t, or ⊆ sums to less than (1 ε)t. Hence, if the Knapsack instance has no solution, then the constructed − SubsetSum instance satisfies OPT < (1 ε)t. − It follows that solving GapSubsetSum on the constructed instance decides whether the given Knapsack instance has a solution, which shows correctness. Finally, we analyze the running time. Since ε = 1/(2W ), invoking a T (n, 1/ε)-time GapSub- setSum algorithm on the constructed instance takes time T (n, 2W )= (T (n,W )). Together with O the first paragraph, we obtain total time (T (n,W )+ W log M) for Knapsack. O Remark 3.3. Knapsack can be solved in time (n + W 2) as follows. Note that any solution O contains at most W/w items of weight exactly w. We may therefore remove all but the W/w most profitable items of any weight w. The number of remaininge items is at most W W/w = (W ). w=1 O After this (n)-time preprocessing, the classic (nW )-time algorithm runs in time (W 2). O O P O e e e 9 In particular, Knapsack is in time (min nW,n + W 2 ). This nicely corresponds to the best- O { } known running time of (min n/ε, n + 1/ε2 ) for ApxSubsetSum [27, 28, 40, 42]. Our reduction O { } indeed transforms the latter time boundse into the former. e 4 Algorithm for Approximating SubsetSum

We now show our reduction from approximating SubsetSum to exactly solving MinConv, proving Theorem 1.1. This implies the approximation scheme of Corollary 1.2. In this section, we work with the following formulation of approximate SubsetSum:

Given X,t and ε> 0, return any subset Y X satisfying ⊆ Σ(Y ) t and Σ(Y ) min OPT, (1 ε)t . ≤ ≥ { − } Note that this is quite a strong problem variant, since for OPT (1 ε)t it requires us to solve ≤ − the problem exactly! In particular, an algorithm for the above problem variant implies a standard approximation scheme for SubsetSum, see also the discussion in Section A. From a high-level perspective, we first use ideas from the known approximation schemes for SubsetSum to carefully define the right notion of approximation and to establish its basic proper- ties (Section 4.1). With respect to this notion of approximation, we then design an approximation algorithm for sumset computation, using an algorithm for MinConv as a black box (Section 4.2). Finally, we adapt the exact pseudopolynomial algorithm for SubsetSum from [12] by replacing its standard sumset subroutine by our novel approximate sumset computation, in addition to sev- eral further changes to make it work in the approximate setting (Section 4.3). This yields an approximation scheme for SubsetSum, with black-box access to a MinConv algorithm. Throughout this section we assume to have access to an algorithm for MinConv running in time TMinConv(n) on sequences of length n. Since this is an exact algorithm, we can assume that TMinConv(n)=Ω(n).

4.1 Preparations We start by defining and discussing our notion of approximation. We will set ∆ = εt in the end.

Definition 4.1 (Approximation). Let t, ∆ N. For any A [t] and b N, we define the lower ∈ ⊆ ∈ and upper approximation of b in A (with respect to universe [t]) as

+ apx−(b, A) := max a A t + 1 a b and apx (b, A) := min a A t + 1 a b . t { ∈ ∪ { } | ≤ } t { ∈ ∪ { } | ≥ } We use the convention max := and min := . ∅ −∞ ∅ ∞ For A, B N, we say that A (t, ∆)-approximates B if A B [t] and for any b B we have ⊆ ⊆ ⊆ ∈ + apx (b, A) apx−(b, A) ∆. t − t ≤ Note that the approximations of b in A are not necessarily elements of A, since we add t + 1. We will sometimes informally say that “b has good approximations in A”, with the meaning that + apxt (b, A) apxt−(b, A) ∆ holds, where t, ∆ are clear from the context. − ≤ + There are two subtle details of this definition. First, we require apxt (b, A) apxt−(b, A) ∆ + − ≤ instead of the more usual apx (b, A) b ∆ and b apx−(b, A) ∆. For an example where this t − ≤ − t ≤ detail is crucially used see the proof of Lemma 4.2 below. This aspect of our definition is inspired by the approximation algorithm of Kellerer et al. [40, 42].

10 Second, we change the upper end by adding t + 1 to A. This relaxation is necessary because our goal will be to compute a set A that (t, ∆)-approximates the set of all subset sums of X below t, or more precisely the set (X; t) := Σ(Y ) Y X, Σ(Y ) t . Computing max( (X; t)) means S { | ⊆ ≤ } S to solve SubsetSum exactly and is thus NP-hard. Therefore, we need a notion of approximation that does not force us to determine max( (X; t)), which is achieved by relaxing the upper end. S We start by establishing some basic properties of our notion of approximation. Lemma 4.2 (Transitivity). If A (t, ∆)-approximates B and B (t, ∆)-approximates C, then A (t, ∆)-approximates C. Proof. Since A B and B C we obtain A C. For any c C, let b and b+ be the lower ⊆ ⊆ ⊆ ∈ − and upper approximations of c in B. Note that b , b+ B t + 1 . For any b B, since A − ∈ ∪ { } ∈ (t, ∆)-approximates B we find good approximations of b in A. Additionally, for b = t + 1 one can + + check that apxt (b, A) = apxt−(b, A) = t + 1, and thus we also have apxt (b, A) apxt−(b, A) ∆. + − + ≤ Therefore, b− and b both have good approximations in A. So let a−− and a− be the lower + ++ and upper approximations of b− in A, and similarly let a − and a be the lower and upper approximations of b+ in A. If c a +, then a c a + form approximations of c in A within ≤ − −− ≤ ≤ − distance ∆. Similarly, if a+ c, then a+ c a++ form approximations of c in A within − ≤ − ≤ ≤ distance ∆. In the remaining case we have

+ + + b− a− c a − b . ≤ ≤ ≤ ≤ + + It follows that a− c a − form approximations of c in A that are within distance ∆, since ≤ ≤ + they are sandwiched between b− and b . Lemma 4.3. If A B C and A (t, ∆)-approximates C, then B (t, ∆)-approximates C. ⊆ ⊆ Proof. We have B C, and for any c C its approximations in B are at least as good as in A. ⊆ ∈ Our notion of approximation also behaves nicely under unions and sumsets, as shown by the following two lemmas.

Lemma 4.4 (Union Property). If A1 (t, ∆)-approximates B1 and A2 (t, ∆)-approximates B2, then A A (t, ∆)-approximates B B . 1 ∪ 2 1 ∪ 2 Proof. Let r 1, 2 , b B . The approximations of b in A A are at least as good as in A . ∈ { } ∈ r 1 ∪ 2 r Lemma 4.5 (Sumset Property). If A1 (t, ∆)-approximates B1 and A2 (t, ∆)-approximates B2, then A1 +t A2 (t, ∆)-approximates B1 +t B2.

Proof. Since Ar Br we obtain A1 +t A2 B1 +t B2. So consider any b1 B1, b2 B2 and set ⊆ + ⊆ ∈ ∈ + b := b1 + b2. Let a1−, a1 be the lower and upper approximations of b1 in A1, and let a2−, a2 be the lower and upper approximations of b2 in A2. Consider the intervals

+ + + + L := [a− + a−, a + a−] [t + 1] and R := (a + a−, a + a ] [t + 1]. 1 2 1 2 ∩ 1 2 1 2 ∩

Note that the endpoints of L and R are contained in (A1 +t A2) t + 1 . Moreover, the interval L + ∪ { +} has length at most a a− ∆, and similarly R has length at most a a− ∆. Finally, since 1 − 1 ≤ 2 − 2 ≤ + + a− + a− b + b a + a , 1 2 ≤ 1 2 ≤ 1 2 we have b L R, and thus either b L or b R. The endpoints of the respective interval ∈ ∪ ∈ ∈ containing b thus form lower and upper approximations of b in A1 +t A2 within distance ∆.

11 We next show that we can always assume approximation sets to have small size, or more precisely to be locally sparse. Definition 4.6 (Sparsity). Let A N and ∆ N. We say that A is ∆-sparse if A [x,x+∆] 2 ⊆ ∈ | ∩ |≤ holds for any x N. If A is ∆-sparse and A (t, ∆)-approximates B, we say that A sparsely (t, ∆)- ∈ approximates B. Lemma 4.7 (Sparsification). Given t, ∆ N and a set3 B [t], in time ( B ) we can compute ∈ ⊆ O | | a set A such that A sparsely (t, ∆)-approximates B. Proof. Recall that our notion of approximation requires A to be a subset of B. We inductively argue as follows. Initially, for A := B it holds that A (t, ∆)-approximates B. If there exist a , a , a A 1 2 3 ∈ with a1 < a2 < a3 a1 + ∆, remove a2 from A. We claim that the resulting set A still (t, ∆)- ≤ + approximates B. Indeed, consider any b B. If b a we have apx−(b, A) apx (b, A) a , and ∈ ≤ 1 t ≤ t ≤ 1 thus a2 is irrelevant. Similarly, a2 is also irrelevant for any b a3. Finally, for any a1 < b < a3, after + ≥ removing a we have apx−(b, A) a and apx (b, A) a , and a a ∆. Thus, after removing 2 t ≥ 1 t ≤ 3 3 − 1 ≤ a2 the set A still (t, ∆)-approximates B. Repeating this rule until it is no longer applicable yields a subset A B that contains at most two numbers in any interval [x,x + ∆]. ⊆ Finally, it is easy to compute A in time ( B ) by one sweep from left to right, assuming that O | | B is given in sorted order. Pseudocode for this is given in Algorithm 1.

Algorithm 1 Sparsification(B,t, ∆): Given t, ∆ > 0 and a set B [t] in sorted order, compute ⊆ a set A that sparsely (t, ∆)-approximates B. We denote the elements of B by B[1],...,B[m]. 1: Initialize A := and n := 0 ∅ 2: for i = 1,...,m do 3: n := n + 1 4: A[n] := B[i] 5: if n 3 and A[n] A[n 2] ∆ then ≥ − − ≤ 6: A[n 1] := A[n] − 7: n := n 1 − 8: return A[1],...,A[n] { }

Lastly, we study how one can shift the value of t. Lemma 4.8 (Down Shifting). Let t,t , ∆ N with t t . If A (t, ∆)-approximates B, then A [t ] ′ ∈ ≥ ′ ∩ ′ (t , ∆)-approximates B [t ]. ′ ∩ ′ Proof. We write A := A [t ] and B := B [t ]. Clearly we have A B . For any b B , note ′ ∩ ′ ′ ∩ ′ ′ ⊆ ′ ∈ ′ that

apxt−′ (b, A′) = apxt−(b, A), since only elements larger than b are removed from A and t + 1 t′ + 1 > b. Moreover, if + + + +≥ apxt (b, A) t′ then apxt (b, A) A′, and thus apxt′ (b, A′) = apxt (b, A). Otherwise, we have + ≤ + ∈ + + apx ′ (b, A ) t + 1 apx (b, A). In any case, we have apx ′ (b, A ) apx (b, A), and therefore t ′ ≤ ′ ≤ t t ′ ≤ t + + apx ′ (b, A′) apx−′ (b, A′) apx (b, A) apx−(b, A) ∆. t − t ≤ t − t ≤ Lemma 4.9 (Up Shifting). Let t,t , ∆ N with t t . If A (t, ∆)-approximates B, then there ′ ∈ ≤ ′ exists u (t ∆,t] such that A (t , ∆)-approximates B [u]. ∈ − ′ ∩ 3Here and in the following, we assume that input sets such as B are given as a sorted list of their elements.

12 Proof. Note that A B [t]. We consider two cases. ⊆ ⊆ Case 1: If max(A) t ∆ then we set u := t, so that B [u]= B. For any b B by assumption + ≤ − ∩ ∈ we have apxt (b, A) apxt−(b, A) ∆. Since max(A) t ∆, we have apxt−(b, A) t ∆ and thus + − ≤+ ≤ − ≤ − apxt (b, A) t. It follows that apxt (b, A) A (instead of being t+1). Therefore, the same elements ≤ + ∈ apx−(b, A), apx (b, A) A also form good approximations of b in A with respect to universe [t ]. t t ∈ ′ Thus, A (t , ∆)-approximates B [u]. ′ ∩ Case 2: If max(A) (t ∆,t] then we set u := max(A). For any b B [u] we have b max(A), ∈ − ∈ ∩ ≤ and thus the upper approximation of b in A is simply the smallest element of A that is at least b. + + As this is independent of the universe [t], we obtain apxt (b, A) = apxt′ (b, A). We also clearly have + + apx−(b, A) = apx−′ (b, A). Hence, apx ′ (b, A) apx−′ (b, A) = apx (b, A) apx−(b, A) ∆, so A t t t − t t − t ≤ (t , ∆)-approximates B [u]. ′ ∩ 4.2 Algorithm for Approximate Sumset Computation

We now present the main connection to MinConv: We show how to compute for given A1, A2 a set A that approximates A + A , by performing two calls to MinConv. At first we set t := , so 1 2 ∞ that we do not have to worry about the upper end. This will be fixed in Lemma 4.11 below.

Lemma 4.10 (Unbounded Sumset Computation). Given t, ∆ N with t ∆ and ∆-sparse sets ∈ ≥ A , A [t], in time (TMinConv(t/∆)) we can compute a set A that ( , ∆)-approximates A +A . 1 2 ⊆ O ∞ 1 2 Proof. To simplify notation, for this proof we introduce the symbol indicating an undefined ⊥ value. We let min = max = . Furthermore, we let x+ = and min x, = max x, = x. ∅ ∅ ⊥ ⊥ ⊥ { ⊥} { ⊥} This gives rise to natural generalizations of MinConv and MaxConv to sequences over Z . ∪ {⊥} We call an entry of such a sequence defined if it is not . Note that since acts as a neutral ⊥ ⊥ element for the min and max operations, we can think of being for MinConv, and for ⊥ ∞ −∞ MaxConv. The fact that these neutral elements, and , are different is the reason why we ∞ −∞ introduce . ⊥ Observe that if MinConv on sequences over M,...,M is in time TMinConv(n), then also {− } MinConv on sequences over M/4,...,M/4 is in time (TMinConv(n)). Indeed, replacing {− }∪{⊥} O by M, any output value in [ M/2, M/2] is computed correctly, while any output value in ⊥ − [3M/4, 2M] corresponds to . Also observe that MaxConv is equivalent to MinConv by negating ⊥ all input and output values, and therefore MaxConv is also in time (TMinConv(n)). O Our algorithm is as follows. Set n := 4 t/∆ . We consider intervals I := [i∆/2, (i + 1)∆/2] for ⌈ ⌉ i 0 i

C− := MinConv(X1, X2), that is, C−[k]= min X1[i]+ X2[j], i+j=k + + C := MaxConv(X1, X2), that is, C [k]= max X1[i]+ X2[j], i+j=k for 0 k< 4n. Finally, we return the set A containing all defined entries of C and C+. ≤ −

13 Clearly, this algorithm runs in time (TMinConv(t/∆)). It remains to prove correctness. Since O every defined entry of Xr corresponds to an element of Ar, it follows that every defined entry of C and C+ corresponds to a sum in A + A . Hence, we have A A + A . − 1 2 ⊆ 1 2 It remains to prove that for any a A , a A their sum a + a has good approximations 1 ∈ 1 2 ∈ 2 1 2 in A. Let 0 i , j < 2n be such that X [i ]= a and X [j ]= a and let k := i + j . Then by ≤ ∗ ∗ 1 ∗ 1 2 ∗ 2 ∗ ∗ ∗ definition of MinConv and MaxConv we have

+ C−[k∗] a + a C [k∗]. (1) ≤ 1 2 ≤ It remains to prove that C+[k ] C [k ] ∆. From the construction of X [2i] and X [2i + 1] it ∗ − − ∗ ≤ r r follows that any defined entry satisfies X [i] [(i 1)∆/4, (i + 1)∆/4]. In particular, the sum of r ∈ − two defined entries satisfies X [i]+ X [j] [(i + j 2)∆/4, (i + j + 2)∆/4]. This yields 1 2 ∈ − + C−[k∗],C [k∗] [(k∗ 2)∆/4, (k∗ + 2)∆/4] . ∈ − ∪ {⊥} Moreover, at least one summand, X [i ]+X [j ]= a +a , is defined, and thus C [k ],C+[k ] = . 1 ∗ 2 ∗ 1 2 − ∗ ∗ 6 ⊥ This yields C+[k ] C [k ] ∆. Together with (1) we see that any sum a + a A + A has ∗ − − ∗ ≤ 1 2 ∈ 1 2 good approximations in A, which finishes the proof.

Lemma 4.11 (Capped Sumset Computation). Let t, ∆ N and B ,B [t]. Set B := B + B ∈ 1 2 ⊆ 1 t 2 and suppose that A1 sparsely (t, ∆)-approximates B1 and A2 sparsely (t, ∆)-approximates B2. In this situation, given A1, A2, t, ∆, we can compute a set A that sparsely (t, ∆)-approximates B in time (TMinConv(t/∆)). We refer to this algorithm as CappedSumset(A , A , t, ∆). O 1 2 Proof. By Lemma 4.5, A1 +t A2 (t, ∆)-approximates B. Using Lemma 4.10, we can compute a set A that ( , ∆)-approximates A + A . By Lemma 4.8 (Down Shifting), A := A [t] (t, ∆)- ′ ∞ 1 2 ′′ ′ ∩ approximates (A + A ) [t] = A + A . Using Lemma 4.7, given A we can compute a set A 1 2 ∩ 1 t 2 ′′ that sparsely (t, ∆)-approximates A′′. By Lemma 4.2 (Transitivity), these three steps imply that A (t, ∆)-approximates B. Since A is ∆-sparse, A also sparsely (t, ∆)-approximates B. Each of these steps runs in time (t/∆) or in time (TMinConv(t/∆)). Since we can assume O O TMinConv(n)=Ω(n), we can bound the total running time by (TMinConv(t/∆)). O 4.3 Algorithms for Subset Sum With the above preparations we are now ready to present our approximation algorithm for Sub- setSum. It is an adaptation of a pseudopolynomial algorithm for SubsetSum [12], mainly in that we use Lemma 4.11 instead of the usual sumset computation by Fast Fourier Transform, but significant changes are required to make this work. Given (X,t, ∆) where X has size n, our goal is to compute a set A that sparsely (t, ∆)- approximates the set (X; t)= Σ(Y ) Y X, Σ(Y ) t . S { | ⊆ ≤ } Definition 4.12. We say that an event happens with high probability if its probability is at least 1 min 1/n, ∆/t c for some constant c> 0 that we are free to choose as any large constant. We − { } say that A w.h.p. (t, ∆)-approximates B if we have

• A B, and ⊆ • with high probability A (t, ∆)-approximates B.

It can be checked that the properties established in Section 4.1 still hold for this new notion of “w.h.p. (t, ∆)-approximates”.

14 4.3.1 Color Coding In this section, we loosely follow [12, Section 3.1]. We present an algorithm ColorCoding (Algo- rithm 2) which solves SubsetSum in case all items are large, that is, X [t/k,t] for a parameter k. ⊆ Lemma 4.13 (Color Coding). Given t, ∆, k N with t ∆ and a set X [t/k,t] of size n, we ∈ ≥ ⊆ can compute a set A that w.h.p. sparsely (t, ∆)-approximates (X; t), in time S 2 n + k TMinConv(t/∆) log(nt/∆) . O · Proof. Denote by X ,...,X 2 a random partitioning ofX, that is, for every x X we choose a 1 k ∈ number j uniformly and independently at random and we put x into X . For any subset Y X j ⊆ with Σ(Y ) t, note that Y k since X [t/k,t], and consider how the random partitioning acts ≤ | |≤ ⊆ on Y . We say that the partitioning splits Y if we have Y X 1 for any 1 j k2. By the | ∩ j| ≤ ≤ ≤ birthday paradox, Y is split with constant probability. More precisely, we can view the partitioning restricted to Y as throwing Y k balls into k2 bins. Thus, the probability that Y is split is equal | |≤ to the probability that the second ball falls into a different bin than the first, the third ball falls into a different bin than the first two, and so on, which has probability

2 2 2 2 Y k 1 k 2 k ( Y 1) k ( Y 1) | | 1 k 1 2 1 − − − | |− − | |− 1 = . k2 · k2 · · · k2 ≥ k2 ≥ − k ≥ 2 4       We make use of this splitting property as follows. Let X := X 0 and j′ j ∪ { }

T := X1′ +t . . . +t Xk′ 2 . Observe that T (X; t), since each sum appearing in T uses any item x X at most once. We ⊆ S ∈ claim that if Y is split, then T contains Σ(Y ). Indeed, in any part X with Y X = 1 we pick j | ∩ j| this element of Y , and in any other part we pick 0 X , to form Σ(Y ) as a sum appearing in ∈ j′ T = X1′ +t . . . +t Xk′ 2 . Hence, we have Σ(Y ) T with probability at least 1/4. To boost the success probability, we ∈ repeat the above random experiment several times. More precisely, for4 r = 1,...,C log(nt/∆) we sample a random partitioning X = X . . . X 2 , set X := X 0 , and consider r,1 ∪ ∪ r,k r,i′ r,i ∪ { } T := X + . . . + X 2 . Since we have Σ(Y ) T with probability at least 1/4, we obtain r r,′ 1 t t r,k′ ∈ r Σ(Y ) T with high probability. Moreover, we have T (X; t). ∈ r r r r ⊆ S Let (X; t) be a sparsification of (X; t), and note that it has size (X; t) = (t/∆) SS∆-sp S S |S∆-sp | O and can be found in linear time by Lemma 4.7. Since we use “with high probability” to denote a probability of at least 1 min 1/n, ∆/t c for large constant c, we can afford a union bound over − { } the (t/∆) elements of (X; t) to infer that with high probability O S∆-sp

∆-sp(X; t) Tr (X; t). S ⊆ r ⊆ S [ Since (X; t) (t, ∆)-approximates (X; t), Lemma 4.3 implies that S∆-sp S

Tr w.h.p. (t, ∆)-approximates (X; t). (2) r S [ We cannot afford to compute any Tr explicitly, but we can compute approximations of these sets. To this end, let Z be the sparsification of X given by Lemma 4.7. We start with A := 0 and r,j r,j′ r,0 { } repeatedly compute the capped sumset with Zr,j, setting Ar,j := CappedSumset(Ar,j 1,Zr,j, t, ∆) − 4Here C is a large constant that governs the “with high probability” bound.

15 for 1 j k2. It now follows inductively from Lemma 4.11 that A sparsely (t, ∆)-approximates ≤ ≤ r,j Xr,′ 1 +t . . . +t Xr,j′ . 2 2 Hence, Ar,k sparsely (t, ∆)-approximates Tr. Let A′ := r Ar,k . By Lemma 4.4, A′ (t, ∆)- approximates T . With (2) and transitivity, A w.h.p. (t, ∆)-approximates (X; t). Finally, r r ′ S S we sparsify A using Lemma 4.7 to obtain a subset A that sparsely (t, ∆)-approximates A . By ′S ′ transitivity, A w.h.p. sparsely (t, ∆)-approximates (X; t). For pseudocode of this, see Algorithm 2. S The running time is immediate from Lemmas 4.7 and 4.11.

Algorithm 2 ColorCoding(X,t, ∆, k): Given t, ∆ N and a set X [t/k,t] in sorted order, we ∈ ⊆ compute a set A that w.h.p. sparsely (t, ∆)-approximates (X; t). S 1: for r = 1,...,C log(nt/∆) do 2: randomly partition X = X . . . X 2 r,1 ∪ ∪ r,k 3: A := 0 r,0 { } 4: for j = 1,...,k2 do 5: X := X 0 r,j′ r,j ∪ { } 6: Zr,j := Sparsification(Xr,j′ , t, ∆) 7: Ar,j := CappedSumset(Ar,j 1,Zr,j, t, ∆) − 2 8: return Sparsification( r Ar,k , t, ∆) S

4.3.2 Greedy We also need a special treatment of the case that all items are small, that is, max(X) ∆. In ≤ this case, we pick any ordering of X = x1,...,xn and let P denote the set of all prefix sums { } j 0,x ,x + x ,x + x + x ,... that are bounded by t, that is, P = x 0 j n [t]. We 1 1 2 1 2 3 { i=1 i | ≤ ≤ }∩ return a sparsification A of P . See Algorithm 3 for pseudocode. P Claim 4.14. P (t, ∆)-approximates (X; t). S Proof. Clearly P (X; t). Moreover, any s [0, max(P )] falls into some interval between two ⊆ S ∈ consecutive prefix sums, and such an interval has length xi for some i. Hence, we have

+ apx (s, P ) apx−(s, P ) x max(X) ∆. t − t ≤ i ≤ ≤ We now do a case distinction on Σ(X). If Σ(X) < t, then observe that max(P ) = Σ(X) = max( (X; t)). Therefore, the interval [0, max(P )] already covers all s (X; t) and we are done. S ∈ S Otherwise, if Σ(X) t, then observe that max(P ) >t ∆, as otherwise we could add the next ≥ − prefix sum to P . In this case, for any s [max(P ),t], ∈ + apx (s, P ) apx−(s, P ) t + 1 max(P ) ∆. t − t ≤ − ≤ In total, every s (X; t) has good approximations in P . ∈ S From Claim 4.14 and transitivity it follows for A = Sparsification(P,t, ∆) that A sparsely (t, ∆)-approximates (X; t). We thus proved the following lemma. S Lemma 4.15 (Greedy). Given integers t, ∆ > 0 and a set X [t] of size n satisfying max(X) ∆, ⊆ ≤ we can compute a set A that sparsely (t, ∆)-approximates (X; t) in time (n). S O

16 Algorithm 3 Greedy(X,t, ∆): Given t, ∆ N and a set X = x ,...,x [t] with max(X) ∆, ∈ { 1 n}⊆ ≤ we compute a set A that sparsely (t, ∆)-approximates (X; t). S 1: P := 0 , s := 0, i := 1 { } 2: while i n and s + x t do ≤ i ≤ 3: s := s + xi 4: P := P s ∪ { } 5: i := i + 1 6: A := Sparsification(P,t, ∆) 7: return A

4.3.3 Recursive Splitting We now present a recursive algorithm making use of ColorCoding and Greedy. (This is a simplified version of the algorithms FasterSubsetSum and ColorCodingLayer from [12], adapted to the approximation setting.) Given a set X N of size n and numbers t, ∆ > 0, our goal is to compute a set A that ⊆ sparsely (t, ∆)-approximates (X; t). We assume that initially t 8∆. We will use parameters S ≥ k and η, which are set before the first call of the algorithm to5 k := max 8,C log3(nt/∆) and { } η := 1/(2 log(t/∆)). We can assume that X [t], since larger numbers cannot be picked for subset ⊆ sums in [t]. We partition X into the large numbers X := X [t/k,t] and the small numbers X := X X . L ∩ S \ L On the large numbers we compute AL := ColorCoding(XL, t, ∆, k), so that AL w.h.p. sparsely (t, ∆)-approximates (X ; t). We then randomly partition the small numbers X into subsets S L S X , X , that is, for any x X we choose a number j 1, 2 uniformly at random and we put x 1 2 ∈ S ∈ { } into Xj. We recursively call the same algorithm on (X1,t′, ∆) and on (X2,t′, ∆) for the new target bound t′ := (1 + η)t/2 + ∆. Call the results of these recursive calls A1, A2. Finally, we combine A1, A2 to AS, and AS, AL to A, by capped sumset computations. We return A. The base case happens when max(X) ∆, where we run Greedy. See Algorithm 4 for pseudocode. ≤ Algorithm 4 RecursiveSplitting(X,t, ∆): Given t, ∆ N and a set X [t] in sorted order, we ∈ ⊆ compute a set A that sparsely (t, ∆)-approximates (X; t). The parameters k, η are set before the S first call of the algorithm to k := max 8,C log3(nt/∆) and η := 1/(2 log(t/∆)). { } 1: if max(X) ∆ then return Greedy(X,t, ∆) ≤ 2: X := X [t/k,t], X := X X L ∩ S \ L 3: randomly partition X = X X S 1 ∪ 2 4: t′ := (1 + η)t/2+∆ 5: AL := ColorCoding(XL, t, ∆, k) 6: A1 := RecursiveSplitting(X1,t′, ∆) 7: A2 := RecursiveSplitting(X2,t′, ∆) 8: AS := CappedSumset(A1, A2, t, ∆) 9: A := CappedSumset(AL, AS, t, ∆) 10: return A

In the following we analyze this algorithm, proving the following lemma.

5Here C is a large constant that governs the “with high probability” bounds.

17 Lemma 4.16 (Recursive Splitting). Given integers t, ∆ > 0 with t 8∆ and a set X [t] of ≥ ⊆ size n, we can compute a set A that sparsely (t, ∆)-approximates (X; t) in time S 8 n + TMinConv(t/∆) log (nt/∆) . O   Recursion Depth Denote by ti the target bound on the i-th level of recursion. Let us first check that t is monotonically decreasing. Initially we assume t 8∆. On any level with t 8∆, the i 0 ≥ i ≥ new target bound satisfies t = (1+ η)t /2+∆ 3 t +∆ < t , where we used our choice of i+1 i ≤ 4 i i η 1/2. Since we also have t t /2, at some point we reach t [4∆, 8∆]. The small items on ≤ i+1 ≥ i i ∈ this level are bounded by t /k ∆, since k 8. Hence, on the next level we will apply Greedy i ≤ ≥ and the recursion stops. In particular, ti is monotonically decreasing throughout. Note that 1+ η i 1+ η j t = t + ∆. i 2 2 0 j

It follows that tlog(t/∆) 1 8∆, so the above argument shows that the recursion stops at the latest − ≤ on level log(t/∆). We have therefore shown that the recursion depth of RecursiveSplitting is at most log(t/∆). In particular, inequality (3) is applicable in each recursive call.

Correctness We inductively prove that with high probability for any recursive call of method RecursiveSplitting(X,t, ∆) the output A sparsely (t, ∆)-approximates (X; t). Note that, as S an output of CappedSumset, A is clearly ∆-sparse, and thus we only need to show that A (t, ∆)- approximates (X; t), see Lemma 4.20. Since the recursion tree has total size (t/∆), we can S O afford a union bound over all recursive calls. In particular, if we prove correctness of one recursive call with high probability, then the whole recursion tree is correct with high probability. Therefore, in the following we consider one recursive call.

Lemma 4.17. With high probability, there exist t ,t [(1 + η)t/2, (1 + η)t/2+∆] such that A 1 2 ∈ (t, ∆)-approximates (X ; t)+ (X ; t )+ (X ; t ). S L t S 1 1 t S 2 2 Proof. We suppress the phrase “with high probability” throughout the proof. Inductively, Ai (t , ∆)-approximates (X ; t ) for t = (1+η)t/2+∆ and any i 1, 2 . By Lemma 4.9, there exists ′ S i ′ ′ ∈ { } a value t [t ∆,t ] such that A (t, ∆)-approximates (X ; t ) [t ]= (X ; t ). Now Lemma 4.11 i ∈ ′ − ′ i S i ′ ∩ i S i i (Capped Sumset Computation) shows that A (t, ∆)-approximates (X ; t )+ (X ; t ). More- S S 1 1 t S 2 2 over, Lemma 4.13 (Color Coding) yields that A (t, ∆)-approximates (X ; t). It follows that the L S L set A (t, ∆)-approximates (X ; t)+ (X ; t )+ (X ; t ). S L t S 1 1 t S 2 2 Lemma 4.18. Let - (X ; t) be the sparsification of (X ; t) given by Lemma 4.7 and let t¯ = S∆ sp S S S (1 + η)t/2. With high probability we have - (X ; t) (X ; t¯)+ (X ; t¯). S∆ sp S ⊆ S 1 t S 2

18 Proof. For any s (X ; t), fix a subset Y X with Σ(Y ) = s and write Y = y ,...,y . ∈ S∆-sp S ⊆ S { 1 ℓ} Let Y := Y X for r 1, 2 . Consider independent random variables Z ,...,Z where Z is r ∩ r ∈ { } 1 ℓ i uniformly distributed in 0,y , and set Z := Z + . . . + Z . Note that Z has the same distribution { i} 1 ℓ as Σ(Y1) and Σ(Y2). Also note that E[Z]=Σ(Y )/2. We use Hoeffding’s inequality on Z to obtain

2λ2 Pr Z E[Z] λ exp . − ≥ ≤ − y2  i i    Since Y is a subset of the small items X , we have y t/k forP all i, and thus y2 y t/k S i ≤ i i ≤ i i · ≤ t2/k. Setting λ := η t, we thus obtain 2 P P η kη2 Pr Z E[Z]+ t exp . ≥ 2 ≤ − 2     By our choice of η := 1/(2 log(t/∆)) and k C log3(nt/∆) we have kη2/2 C log(nt/∆). More- ≥ ≥ 8 over, since E[Z]=Σ(Y )/2 t/2, we obtain ≤ ∆ C/8 Pr Z (1 + η) t Pr Z E[Z]+ η t . ≥ 2 ≤ ≥ 2 ≤ tn h i     For large C, this shows that with high probability Σ(Y ), Σ(Y ) (1 + η) t = t¯, and hence s = 1 2 ≤ 2 Σ(Y ) (X ; t¯)+ (X ; t¯). Since (X ; t) has size (t/∆), we can afford a union bound over ∈ S 1 t S 2 S∆-sp S O all s (X ; t) to obtain that with high probability (X ; t) (X ; t¯)+ (X ; t¯). ∈ S∆-sp S S∆-sp S ⊆ S 1 t S 2 Observation 4.19. For any partitioning Z = Z Z we have (Z ,t)+ (Z ,t)= (Z; t). 1 ∪ 2 S 1 t S 2 S Proof. Follows from the fact that any subset sum of Z can be uniquely written as a sum of a subset sum of Z1 and a subset sum of Z2. Lemma 4.20. A w.h.p. (t, ∆)-approximates (X; t). S Proof. Let t ,t be as in Lemma 4.17, in particular t¯ = (1+ η)t/2 t ,t (1 + η)t/2+∆ t. 1 2 ≤ 1 2 ≤ ≤ Using these bounds, Lemma 4.18, and Observation 4.19, we obtain with high probability

(X ; t) (X ; t¯)+ (X ; t¯) (X ; t )+ (X ; t ) (X ; t)+ (X ; t)= (X ; t). S∆-sp S ⊆ S 1 t S 2 ⊆ S 1 1 t S 2 2 ⊆ S 1 t S 2 S S Since (X ; t) (t, ∆)-approximates (X ; t), it now follows from Lemma 4.3 that with high S∆-sp S S S probability the sumset (X ; t )+ (X ; t ) (t, ∆)-approximates (X ; t). S 1 1 t S 2 2 S S Using Lemma 4.5 (Sumset Property) and Observation 4.19, we obtain that with high probability

(X ; t)+ (X ; t )+ (X ; t ) (t, ∆)-approximates (X ; t)+ (X ; t)= (X; t). S L t S 1 1 t S 2 2 S L t S S S Lemma 4.17 and transitivity now imply that with high probability A (t, ∆)-approximates (X; t). S It is easy to see that the inclusion A (X; t) holds deterministically (i.e., with probability 1), ⊆ S and thus we even have that A w.h.p. (t, ∆)-approximates (X; t). S This finishes the proof of correctness.

19 Running Time Lines 1-4 of Algorithm 4 take time ( X ), which sums to (n) on each level of O | | O recursion, or (n log(t/∆)) overall. On the i-th level of recursion, calling ColorCoding takes time O 2 (( X + k TMinConv(t /∆)) log(nt/∆)), O | L| · i and calling CappedSumset is dominated by this running time. Since every item is large in exactly one recursive call, the terms XL simply sum up to n. For the remainder, for any 0 i log(t/∆) we i | | i i ≤ ≤ have 2 instances, each with target bound ti 2t/2 + 4∆. Note that 2 ti 6t, since i log(t/∆). ≤ i · ≤ ≤ Hence, by Lemma 4.21 below, we can solve 2 MinConv instances, each of size at most ti/∆, in total time (TMinConv(t/∆)). We can thus bound the time (k2 TMinConv(t /∆) log(nt/∆)) O O · i summed over all recursive calls on level i by (k2 TMinConv(t/∆) log(nt/∆)). Over all levels, there O · is an additional factor log(t/∆). It follows that the total running time is

2 n + k log(t/∆) TMinConv(t/∆) log(nt/∆) . O · 3 8 Plugging in k = (log (nt/∆)) yields a running time of (( n + TMinConv (t/∆)) log (nt/∆)). It O O remains to prove the following lemma.

Lemma 4.21. There is an algorithm that solves m given MinConv instances of sizes n1,...,nm in total time (TMinConv( n )). O i i Note that for any “natural”P time bound, say TMinConv(n) = Θ(nc), the lemma statement is immediate. Indeed, we must have c 1, since writing the output requires time Θ(n). This implies ≥ nc + . . . + nc (n + . . . + n )c. It follows that we can solve m given MinConv instances of sizes 1 m ≤ 1 m n ,...,n in total time TMinConv(n )= (TMinConv( n )). The lemma proves that the same 1 m i i O i i statement also holds for “unnatural” time bounds, by a reduction that packs multiple instances P P into one.

Proof. Given A ,B Nn1 ,...,A ,B Nnm our goal is to compute C Nn1 ,...,C Nnm 1 1 ∈ m m ∈ 1 ∈ m ∈ satisfying Cr[k] = min0 i k Ar[i]+ Br[k i] for any 1 r m and 0 k

The lemma follows from this claim, as we can infer C1,...,Cm from C. To prove the claim, in one direction observe that

2 2 C[4sr + k] min A[2sr + i]+ B[2sr + k i]= r 4M + min Ar[i]+ Br[k i]= r 4M + Cr[k]. ≤ 0 i k − · 0 i k − · ≤ ≤ ≤ ≤

In the other direction, by construction we have C[4sr + k] = A[2sx + i]+ B[2sy + j] for some 1 x,y m and 0 i

20 of A and B are . We extend the notation s to real numbers z [1,m + 1) by interpolating ∞ z ∈ linearly, that is, sz := ( z + 1 z) s z + (z z ) s z +1. Since n1 . . . nm are sorted, the ⌊ ⌋ − · ⌊ ⌋ − ⌊ ⌋ · ⌊ ⌋ ≥ ≥ function s is concave, in other words we have (s + s ′ )/2 s ′ for any z, z [1,m + 1). z z z ≤ (z+z )/2 ′ ∈ Hence,

4s 2s + 2s = 2s + n + 2s + n > 2s + i + 2s + j = 4s + k 4s . (x+y+1)/2 ≥ x+1/2 y+1/2 x x y y x y r ≥ r By monotonicity, this yields (x + y + 1)/2 > r, resulting in x + y > 2r 1. Since x, y, r are integers, − we obtain x + y 2r. We now consider three cases. ≥ Case 1: For x + y 2r + 1, we have ≥ C[4s + k]= A[2s + i]+ B[2s + j] (x2 + y2) 2M (x2 + (2r + 1 x)2) 2M r x y ≥ · ≥ − · 2r + 1 2 4M > (r2 + 1) 4M ≥ 2 · · > r2 4M + C [k]. · r Case 2: Similarly, for x + y = 2r and x = y we have 6 C[4s + k]= A[2s + i]+ B[2s + j] (x2 + (2r x)2) 2M (r 1)2 + (r + 1)2 2M r x y ≥ − · ≥ − · = (r2 + 1) 4M > r2 4M + C [k]. · · r Case 3: In the remaining case x = y = r, we have i + j = k and

C[4s + k]= A[2s + i]+ B[2s + j]= r2 4M + A [i]+ B [j] r2 4M + C [k]. r r r · r r ≥ · r In all cases we have C[4s + k] r2 4M + C [k]. Together with the first direction, this proves the r ≥ · r claim and thus the lemma.

4.3.4 Finishing the Proof We show how to use RecursiveSplitting to obtain an approximation scheme for SubsetSum in time (n + TMinConv(1/ε)). Note that this proves Theorem 1.1 as well as Corollary 1.2. O Given X,t and ε> 0, let OPT := max( (X; t)). Set ∆ := min εt, t/8 and call the procedure S { } RecursiveSplittinge (X,t, ∆) to obtain a set A that w.h.p. (t, ∆)-approximates (X; t). S Claim 4.22. With high probability, we have max(A) min OPT, (1 ε)t . ≥ { − } + Proof. Consider apxt (OPT, A) and apxt−(OPT, A). Since (X; t) does not contain any numbers in + S + (OPT,t], and A (X; t), we have apxt (OPT, A) OPT,t + 1 . If apxt (OPT, A) = OPT, then ⊆ S ∈ { + } A contains OPT, so max(A) OPT. Otherwise, if apx (OPT, A)= t + 1, then apx−(OPT, A) ≥ t t ≥ apx+(OPT, A) ∆ >t εt. In particular, max(A) (1 ε)t. t − − ≥ − We have thus shown how to compute a subset sum max(A) with max(A) min OPT, (1 ε)t . ≥ { − } It remains to determine a subset Y X summing to max(A). To this end, we retrace the steps of ⊆ the algorithm, using the following idea. If a CappedSumset(A , A , t, ∆), then a A + A , and ∈ 1 2 ∈ 1 2 thus we can simply iterate over all a A and check whether a a A , to reconstruct a pair 1 ∈ 1 − 1 ∈ 2 a A , a A with a = a + a in linear time. Starting with max(A), we perform this trick in 1 ∈ 1 2 ∈ 2 1 2 each recursive call of the algorithm, to reconstruct a subset summing to max(A). 8 The total running time of this algorithm is ((n + TMinConv(1/ε)) log (n/ε)). O

21 5 Approximation Scheme for Partition

The goal of this section is to prove Theorem 1.4 and thus Corollary 1.5. We restate Theorem 1.4 here for convenience (slightly reformulated).

Theorem 5.1. For any 1 L 1/ε, we can approximate Partition in time ≤ ≤

L 1 2 n n + + L TMinConv log . O ε · L ε · ε    ·    Recall that (X) is the set of all subset sums of X. On a high level, for X = x ,...,x S { 1 n} we compute (X) by evaluating the sumset (X) = 0,x + . . . + 0,x in a tree-like fashion. S S { 1} { n} In the bottom half of this tree, we approximate sumsets by Lemma 4.10 from our SubsetSum approximation scheme, see Lemma 5.2. In the top half, where it remains to combine L intermediate sumsets, we first round all sums computed so far to multiples of ε Σ(X)/L; this is valid by · Lemma 5.4. Then we combine the rounded sets by using exact sumset computation via Fast Fourier Transform, see Lemma 5.3. We start by formalizing these steps in the following lemmas, and then we combine them to obtain our approximation scheme.

Lemma 5.2 (Bottom Half). Given a set X N of size n and ∆ N, we can compute in time ⊆ ∈ (n + TMinConv(Σ(X)/∆) log n) a set Z that sparsely ( , ∆)-approximates (X). O ∞ S Proof. Let X = x ,...,x and note that (X) = 0,x + . . . + 0,x . We compute this { 1 n} S { 1} { n} sumset in a tree-like fashion. On level ℓ of this tree, we have a partitioning X . . . X ℓ 1 ∪ ∪ n/2 of X and we have already computed sets Z ,...,Z ℓ such that Z sparsely ( , ∆)-approximates 1 n/2 i ∞ (X ). This holds on level ℓ = 0 with X = x and Z = 0,x . Now we argue how to S i i { i} i { i} go from level ℓ to level ℓ + 1. On level ℓ + 1 the partitioning will consist of the sets Xi′ := X2i 1 X2i. Accordingly, we invoke Lemma 4.10 to compute a set Zi′ that sparsely ( , ∆)- − ∪ ∞ approximates Z2i 1 + Z2i. By transitivity (Lemma 4.2), Zi′ also sparsely ( , ∆)-approximates − ∞ (X2i 1)+ (X2i) = (Xi′). At level ℓ = log n we then obtain a set Z that sparsely ( , ∆)- S − S S ∞ approximates (X). Since Zi (Xi) [Σ(Xi)], all calls to Lemma 4.10 on level ℓ in total take n/2ℓ S ⊆ S ⊆ time TMinConv(Σ(X )/∆) = (TMinConv(Σ(X)/∆)), by Lemma 4.21. Over log n levels this i=1 i O yields the claimed running time. P Lemma 5.3 (Top Half). Given sets Z ,...,Z N, we can compute their sumset Z + . . . + Z 1 L ⊆ 1 L in time (σ log σ log L), where σ := max(Z )+ . . . + max(Z ). O 1 L Proof. Using Fast Fourier Transform, we can compute a sumset A + B [U] in time (U log U). ⊆ O In particular, we can compute Z1 + Z2 in time

(max(Z ) + max(Z )) log(max(Z ) + max(Z )) = (max(Z ) + max(Z )) log σ . O 1 2 1 2 O 1 2 Thus, we can compute all pairwise sumsets Z + Z ,Z + Z ,Z + Z ,... in total time (σ log σ). 1 2 3 4 5 6 O This reduces the problem to an instance of size L/2. Using the same algorithm recursively, af- ter log L such rounds we have computed the sumset Z1 + . . . + ZL. This runs in total time (σ log σ log L). O Note that the value of σ does not change throughout this algorithm, since max(Z1 + Z2)+ max(Z3 + Z4)+ . . . = max(Z1) + max(Z2) + max(Z3) + max(Z4)+ . . ..

22 Lemma 5.4 (Weak Rounding). For any set Z N and R N we write Z/R := z/R z Z ⊆ ∈ ⌊ ⌋ {⌊ ⌋ | ∈ } and R Z := R z z Z . · { · | ∈ } Let Z ,...,Z N and let R N. For any sum s in Z + . . . + Z and the corresponding sum 1 L ⊆ ∈ 1 L s in R ( Z /R + . . . + Z /R ) we have s s s L R. ′ · ⌊ 1 ⌋ ⌊ L ⌋ ≥ ′ ≥ − · Proof. Consider any sum s = s + . . . + s Z + . . . + Z and the corresponding sum s = 1 L ∈ 1 L ′ R ( s /R + . . . + s /R ). Since we round down, we have s s. Moreover, we have · ⌊ 1 ⌋ ⌊ L ⌋ ′ ≤

s′ R ((s /R 1) + . . . + (s /R 1)) = s L R. ≥ · 1 − L − − · We are now ready to describe our approximation scheme for Partition. Given a set X N ⊆ of size n, let OPT := max Σ(Y ) Y X, Σ(Y ) σ/2 and set σ := Σ(X) and ∆ := ε σ/4. We { | ⊆ ≤ } · proceed as follows.

1. We partition X into X . . . X such that each X satisfies (1) Σ(X ) 4σ/L or (2) X = 1. 1 ∪ ∪ L i i ≤ | i| To this end, items larger than 2σ/L get assigned to singleton parts; this uses at most L/2 parts. We partition the remaining items greedily by adding items to Xi until its sum is more than 2σ/L; this results in at most L/2 non-empty parts, each with a sum in [2σ/L, 4σ/L].

2. Next, we compute sets Z ,...,Z such that Z sparsely ( , ∆)-approximates (X ). For 1 L i ∞ S i parts X with X = 1 we can simply set Z := 0 X = (X ). For parts X with i | i| i { } ∪ i S i i Σ(X ) 4σ/L, Lemma 5.2 computes the required set Z in time i ≤ i Σ(Xi) 1 X + TMinConv log n = X + TMinConv log n . O | i| ∆ O | i| L ε       ·   Over all 1 i L, the total running time of this step is (n + L TMinConv(1/(L ε)) log n). ≤ ≤ O · · 3. Next, we round every Z to Z˜ := Z /R for R := ∆/L. We compute Z˜ + . . . + Z˜ using i i ⌊ i ⌋ 1 L Lemma 5.3. We multiply each number in the resulting set by R, to obtain S = R ( Z /R +. . .+ · ⌊ 1 ⌋ Z /R ). Note that max(Z˜ )+. . .+max(Z˜ ) σ/R, so this step runs in time ( σ log σ log L)= ⌊ L ⌋ 1 L ≤ O R R ( L log L log L). O ε ε 4. Finally, pick the largest number in S that is at most σ/2. Retrace the previous steps to construct a corresponding subset Y X. If Σ(Y ) σ/2 then return Y := Y , otherwise return ⊆ ≤ ′ Y := X Y . ′ \ Correctness: Let Y X be a subset summing to OPT. Since Z ( , ∆)-approximates (X ), ∗ ⊆ i ∞ S i by Lemma 4.5 Z + . . . + Z ( , ∆)-approximates (X )+ . . . + (X )= (X). Hence, there is 1 L ∞ S 1 S L S a sum in Z + . . . + Z [OPT ∆, OPT]. By Lemma 5.4, the corresponding sum in S lies in 1 L ∩ − [OPT 2∆, OPT]. In particular, the largest number in S that is at most σ/2 is at least OPT 2∆. − − Now pick any number in S [OPT 2∆, σ/2]. This corresponds to a sum in Z + . . . + Z lying ∩ − 1 k in the range [OPT 2∆, σ/2 + ∆], by Lemma 5.4. In particular, it corresponds to a subset Y X − ⊆ summing to a number in [OPT 2∆, σ/2 + ∆]. By possibly replacing Y by X Y , we obtain a − \ subset Y of X summing to a number in [OPT 2∆, σ/2]. Since any subset of X summing to at ′ − most σ/2 sums to at most OPT, we obtain Σ(Y ) [OPT 2∆, OPT]. Since we set ∆ := εσ/4, ′ ∈ − we obtain the desired (1 ε)OPT Σ(Y ) OPT if we assume OPT σ/4. − ≤ ′ ≤ ≥ It remains to argue why we can assume OPT σ/4. Write X = x ,...,x and suppose that ≥ { 1 n} xn is the largest item in X. If xn > σ/2, then xn cannot be picked by any subset summing to at most σ/2, which yields σ/2 > σ xn = x1 + . . . + xn 1 = OPT, so we can solve the problem in − − linear time (n). Otherwise, all items are bounded by at most σ/2, so there exists 1 i n such O ≤ ∗ ≤

23 i∗ i∗ n that the prefix sum i=1 xi lies in [σ/4, 3σ/4]. It follows that one of i=1 xi or i=i∗+1 xi lie in [σ/4, σ/2], which shows OPT σ/4. This justifies our assumption OPT σ/4 from above and P ≥ P ≥ P thus finishes the correctness argument.

Running Time: To analyze the running time of the retracing in step 4, we use the following: After we have computed a sumset A + B [U] in time (U log U), given a number x A + B we ⊆ O ∈ can find a pair a A, b B with a + b = x in time (U), by simply iterating over all a A and ∈ ∈ O ∈ checking whether x a B. Similarly, after we have computed C = MinConv(A, B) for vectors − ∈ A, B NU , given an output index k we can find a pair i + j = k such that A[i]+ B[j] = C[k] in ∈ time (U), again by simple brute force. Therefore, if we perform all previous steps backwards, we O can reconstruct a corresponding subset by spending asymptotically at most as much time as these steps took originally. The total time is thus dominated by steps 2 and 3, 1 L L n + L TMinConv log n + log log L . O · L ε ε ε   ·   We can roughly bound this by

L 1 2 n n + + L TMinConv log , O ε · L ε · ε    ·    which is the bound claimed in Theorem 5.1. This finishes the proof.

6 Open Problems

A natural first question is to derandomize our reduction and the resulting approximation scheme for SubsetSum. Another question is to prove hardness of SubsetSum for other values of ε. For example, when ε is much smaller than 1/n, is the (n/ε)-time algorithm conditionally (almost) O optimal, or is there room for improvement? Lastly, it would be interesting to understand to what extend our ideas and the arguments of [50], most notablye [50, Section 5.3], can be brought together, yielding further improvements for approximate Partition. It is worth noting that gluing them together is a non-trivial task, mostly due to the fact that our algorithm does not seem to benefit from a distinction between “large” and “small” items, as in the algorithm of [50]. Nevertheless, getting our hands on the additive structure of the problem seems the correct way to proceed, and incorporating the ideas in [50] is a potential first step towards this goal.

References

[1] Amir Abboud, Karl Bringmann, Danny Hermelin, and Dvir Shabtay. SETH-based lower bounds for Subset Sum and Bicriteria Path. In SODA, pages 41–57. SIAM, 2019.

[2] Amir Abboud, Aviad Rubinstein, and R. Ryan Williams. Distributed PCP theorems for hardness of approximation in P. In FOCS, pages 25–36. IEEE, 2017.

[3] Per Austrin, Petteri Kaski, Mikko Koivisto, and Jesper Nederlof. Subset Sum in the absence of concentration. In STACS, volume 30 of LIPIcs, pages 48–61, 2015.

[4] Per Austrin, Petteri Kaski, Mikko Koivisto, and Jesper Nederlof. Dense Subset Sum may be the hardest. In STACS, volume 47 of LIPIcs, pages 13:1–13:14, 2016.

24 [5] Kyriakos Axiotis, Arturs Backurs, Ce Jin, Christos Tzamos, and Hongxun Wu. Fast Modular Subset Sum using linear sketching. In SODA, pages 58–69. SIAM, 2019.

[6] Kyriakos Axiotis and Christos Tzamos. Capacitated dynamic programming: Faster Knapsack and graph algorithms. In ICALP, volume 132 of LIPIcs, pages 19:1–19:13, 2019.

[7] Arturs Backurs, , and Ludwig Schmidt. Better approximations for tree sparsity in nearly-linear time. In SODA, pages 2215–2229. SIAM, 2017.

[8] Nikhil Bansal, Shashwat Garg, Jesper Nederlof, and Nikhil Vyas. Faster space-efficient algo- rithms for Subset Sum, k-Sum, and related problems. SIAM J. Comput., 47(5):1755–1777, 2018.

[9] MohammadHossein Bateni, MohammadTaghi Hajiaghayi, Saeed Seddighin, and Cliff Stein. Fast algorithms for knapsack via convolution and prediction. In STOC, pages 1269–1282. ACM, 2018.

[10] Richard E. Bellman. Dynamic Programming. Princeton University Press, 1957.

[11] David Bremner, Timothy M. Chan, Erik D. Demaine, Jeff Erickson, Ferran Hurtado, John Iacono, Stefan Langerman, Mihai Patrascu, and Perouz Taslakian. Necklaces, convolutions, and X+Y. Algorithmica, 69(2):294–314, 2014.

[12] Karl Bringmann. A near-linear pseudopolynomial time algorithm for Subset Sum. In SODA, pages 1073–1084. SIAM, 2017.

[13] Karl Bringmann, Marvin K¨unnemann, and Karol Wegrzycki. Approximating APSP without scaling: equivalence of approximate min-plus and exact min-max. In STOC, pages 943–954. ACM, 2019.

[14] Karl Bringmann and Vasileios Nakos. Top-k-convolution and the quest for near-linear output- sensitive subset sum. In STOC, pages 982–995. ACM, 2020.

[15] Michael R. Bussieck, Hannes Hassler, Gerhard J. Woeginger, and Uwe T. Zimmermann. Fast algorithms for the maximum convolution problem. Oper. Res. Lett., 15(3):133–141, 1994.

[16] Parinya Chalermsook, Marek Cygan, Guy Kortsarz, Bundit Laekhanukit, Pasin Manurangsi, Danupon Nanongkai, and Luca Trevisan. From Gap-ETH to FPT-inapproximability: Clique, Dominating Set, and more. In FOCS, pages 743–754. IEEE, 2017.

[17] Timothy M. Chan. Approximation schemes for 0-1 Knapsack. In SOSA@SODA, volume 61 of OASICS, pages 5:1–5:12, 2018.

[18] Timothy M. Chan and Moshe Lewenstein. Clustered integer 3SUM via Additive Combinatorics. In STOC, pages 31–40. ACM, 2015.

[19] Timothy M. Chan and Ryan Williams. Deterministic APSP, orthogonal vectors, and more: Quickly derandomizing Razborov-Smolensky. In SODA, pages 1246–1255. SIAM, 2016.

[20] Lijie Chen. On the hardness of approximate and exact (bichromatic) maximum inner product. In CCC, volume 102 of LIPIcs, pages 14:1–14:45, 2018.

[21] Lijie Chen, Shafi Goldwasser, Kaifeng Lyu, Guy N. Rothblum, and Aviad Rubinstein. Fine- grained complexity meets IP = PSPACE. In SODA, pages 1–20. SIAM, 2019.

25 [22] Lijie Chen and Ryan Williams. An equivalence class for Orthogonal Vectors. In SODA, pages 21–40. SIAM, 2019.

[23] Marek Cygan, Holger Dell, Daniel Lokshtanov, D´aniel Marx, Jesper Nederlof, Yoshio Okamoto, Ramamohan Paturi, Saket Saurabh, and Magnus Wahlstr¨om. On problems as hard as CNF- SAT. ACM Trans. Algorithms, 12(3):41:1–41:24, 2016.

[24] Marek Cygan, Marcin Mucha, Karol Wegrzycki, and Michal Wlodarczyk. On problems equiv- alent to (min,+)-convolution. ACM Trans. Algorithms, 15(1):14:1–14:25, 2019.

[25] Andre Esser and Alexander May. Better sample - random Subset Sum in 20.255n and its impact on decoding random linear codes. CoRR, abs/1907.04295, 2019.

[26] Zvi Galil and Oded Margalit. An almost linear-time algorithm for the dense subset-sum problem. SIAM Journal on Computing, 20(6):1157–1189, 1991.

[27] George V. Gens and Eugene V. Levner. Approximation algorithm for some scheduling prob- lems. Engrg. Cybernetics, 6:38–46, 1978.

[28] George V. Gens and Eugene V. Levner. Computational complexity of approximation algo- rithms for combinatorial problems. In MFCS, volume 74 of LNCS, pages 292–300, 1979.

[29] George V. Gens and Eugene V. Levner. Fast approximation algorithms for Knapsack type problems. In Optimization Techniques, pages 185–194. Springer, 1980.

[30] George V. Gens and Eugene V. Levner. A fast approximation algorithm for the Subset-Sum problem. INFOR: Information Systems and Operational Research, 32(3):143–148, 1994.

[31] Brian Hayes. Computing science: The easiest hard problem. American Scientist, 90(2):113– 117, 2002.

[32] Oscar H. Ibarra and Chul E. Kim. Fast approximation algorithms for the Knapsack and Sum of Subset problems. J. ACM, 22(4):463–468, 1975.

[33] Klaus Jansen and Lars Rohwedder. On integer programming and convolution. In ITCS, volume 124 of LIPIcs, pages 43:1–43:17, 2019.

[34] Ce Jin. An improved FPTAS for 0-1 Knapsack. In ICALP, volume 132 of LIPIcs, pages 76:1–76:14, 2019.

[35] Ce Jin and Hongxun Wu. A simple near-linear pseudopolynomial time randomized algorithm for Subset Sum. In SOSA@SODA, volume 69 of OASICS, pages 17:1–17:6, 2019.

[36] . Probabilistic analysis of some bin-packing problems. In FOCS, pages 107–111. IEEE, 1982.

[37] Richard M. Karp. Reducibility among combinatorial problems. In Complexity of Computer Computations, The IBM Research Symposia Series, pages 85–103. Plenum Press, New York, 1972.

[38] Richard M. Karp. The fast approximate solution to hard combinatorial problems. In Proc. 6th Southeastern Conference on Combinatorics, Graph Theory and Computing, pages 15–31, 1975.

26 [39] Karthik C. S., Bundit Laekhanukit, and Pasin Manurangsi. On the parameterized complexity of approximating Dominating Set. J. ACM, 66(5):33:1–33:38, 2019.

[40] Hans Kellerer, Renata Mansini, Ulrich Pferschy, and Maria Grazia Speranza. An efficient fully polynomial approximation scheme for the Subset-Sum problem. J. Comput. Syst. Sci., 66(2):349–370, 2003.

[41] Hans Kellerer, Ulrich Pferschy, and David Pisinger. Knapsack Problems. Springer, 2004.

[42] Hans Kellerer, Ulrich Pferschy, and Maria Grazia Speranza. An efficient approximation scheme for the Subset-Sum problem. In ISAAC, volume 1350 of LNCS, pages 394–403, 1997.

[43] Konstantinos Koiliaris and Chao Xu. A faster pseudopolynomial time algorithm for Subset Sum. In SODA, pages 1062–1072. SIAM, 2017.

[44] Marvin K¨unnemann, Ramamohan Paturi, and Stefan Schneider. On the fine-grained com- plexity of one-dimensional dynamic programming. In ICALP, volume 80 of LIPIcs, pages 21:1–21:15, 2017.

[45] Eduardo Sany Laber, Wilfredo Bardales Roncalla, and Ferdinando Cicalese. On lower bounds for the maximum consecutive subsums problem and the (min,+)-convolution. In ISIT, pages 1807–1811. IEEE, 2014.

[46] Eugene L. Lawler. Fast approximation algorithms for Knapsack problems. Math. Oper. Res., 4(4):339–356, 1979.

[47] Andrea Lincoln, Virginia Vassilevska Williams, Joshua R. Wang, and R. Ryan Williams. De- terministic time-space trade-offs for k-SUM. In ICALP, volume 55 of LIPIcs, pages 58:1–58:14, 2016.

[48] Silvano Martello and Paolo Toth. Knapsack Problems: Algorithms and Computer Implemen- tations. John Wiley & Sons, Inc., 1990.

[49] and Martin Hellman. Hiding information and signatures in trapdoor knapsacks. IEEE transactions on Information Theory, 24(5):525–530, 1978.

[50] Marcin Mucha, Karol Wegrzycki, and Michal Wlodarczyk. A subquadratic approximation scheme for Partition. In SODA, pages 70–88. SIAM, 2019.

[51] Jesper Nederlof. A short note on Merlin-Arthur protocols for Subset Sum. Inf. Process. Lett., 118:15–16, 2017.

[52] R. Ryan Williams. Faster All-Pairs Shortest Paths via circuit complexity. SIAM J. Comput., 47(5):1965–1985, 2018.

A Problem Variants of SubsetSum

Recall that an approximation scheme for SubsetSum asks to compute a subset Y X with ⊆ (1 ε)OPT Σ(Y ) OPT, where OPT = max Σ(Y ) Y X, Σ(Y ) t . Beyond this standard − ≤ ≤ { | ⊆ ≤ } approximation goal, one can define many different variants of approximating SubsetSum. For instance, computing such a subset Y is not necessarily equivalent to just computing a number R

27 with (1 ε)OPT R OPT. To avoid these details in the problem definition, we consider − ≤ ≤ the following two variants, which are in some sense the hardest and the simplest possible variants (subject to the strict constraint Σ(Y ) t): ≤ • ApxSubsetSum: Given X,t and ε > 0, return any subset Y X satisfying Σ(Y ) t and ⊆ ≤ Σ(Y ) min OPT, (1 ε)t . ≥ { − } • GapSubsetSum: Given X,t and ε > 0, distinguish whether OPT = t or OPT < (1 ε)t. If − OPT [(1 ε)t,t) the output can be arbitrary. ∈ − Note that in Section 4 we solved the harder problem variant ApxSubsetSum by a reduction to MinConv, while in Section 3 we reduced MinConv to the simpler problem GapSubsetSum. Also note that any algorithm for ApxSubsetSum also solves GapSubsetSum, since if OPT = t then the algorithm returns a set with sum in [(1 ε)t,t], while if OPT < (1 ε)t then the algorithm − − returns a set with sum OPT < (1 ε)t. Therefore, we obtain a full equivalence of ApxSubsetSum, − GapSubsetSum, and MinConv. Intuitively, ApxSubsetSum is the hardest and GapSubsetSum is the simplest variant of ap- proximating SubsetSum. There are several further variants that are intermediate between Apx- SubsetSum and GapSubsetSum, in the sense that any algorithm for ApxSubsetSum also solves the intermediate variant and any algorithm for the intermediate variant also solves GapSubset- Sum. Since we prove ApxSubsetSum and GapSubsetSum to be equivalent, all intermediate variants are also equivalent. Examples of intermediate problem variants are as follows (we note that some of the reductions among these problem variants change ε by a constant factor):

• Return any value in [(1 ε)OPT, OPT]. − • Return any subset Y X with (1 ε)OPT Σ(Y ) t. ⊆ − ≤ ≤ • If OPT = t, compute a subset Y X with (1 ε)t Σ(Y ) t, otherwise the output can be ⊆ − ≤ ≤ arbitrary.

• Distinguish whether OPT (1 ε/2)t or OPT < (1 ε)t. If OPT [(1 ε)t, (1 ε/2)t) the ≥ − − ∈ − − output can be arbitrary.

28