title: Group incoming and outgoing invoices to make their sum 0
body: <p>I've faced an interesting problem today, and decided to write an algorithm in C# to solve it.</p>
  
  <p>There are incoming invoices with negative totals and outgoing invoices with positive totals. The task is to make groups out of these invoices, where the total of the invoices adds up to exactly 0. Each group can contain unlimited members, so if there are two positive and one negative members but they total value is 0, it's okay. </p>
  
  <p>We try to minimize the sum of the remaining invoices' totals, and there are no other constraints at all.</p>
  
  <p>I'm wondering if this problem could be traced back to a known problem, and if not, which would be the most effective way to do this. The naive approach would be to separate incoming and outgoing invoices into two different groups, sort by total, then to try add invoices one by one until zero is reached or the sign has changed. However, this presumes that the invoices in a group should be approximately of the same magnitude, which is not true (one huge incoming invoice could be put against 10 smaller outgoing ones)</p>
  
  <p>Any ideas?</p>