JAVA problem solve for google code jam (Charging Chaos 2014)