Google Code Jam solution to "Store Credit"