title: An algorithm for solving Google Code Jam tutorial problem C
body: <p>I'd like to understand the algorithm that solves <a href="http://code.google.com/codejam/contest/dashboard?c=32004#s=p2" rel="nofollow">Google Code Jam, Tutorial, Problem C</a>. So far I wrote <a href="https://github.com/ripper234/Basic/blob/master/java/src/main/java/org/basic/google/codejam/practicecontest/ProblemCSolver.java" rel="nofollow">my own basic implementation</a> that solves the small problem. I find that it's unable to deal with the large problem (complexity O(min(n, 2*k)! which is 30! in the larger data set).</p>
  
  <p>I found this <a href="http://code.google.com/codejam/contest/scoreboard?c=32004#vf=1" rel="nofollow">solution page</a>, but the solutions are of course not documented (there's a time limit to the context). I saw that at least one of the solutions used the <a href="http://en.wikipedia.org/wiki/Disjoint-set_data_structure" rel="nofollow">Union Find data structure</a>, but I don't understand how it's applied here.</p>
  
  <p>Does anyone know of a page with the algorithms that solve these problems, not just code?</p>