recursive solutin for spoj COINS. look at STL map now?