Topcoder Member SRM 478 "KiwiJuiceEasy"
問題:http://www.topcoder.com/stat?c=problem_statement&pm=11020 (要ログイン)
public class KiwiJuiceEasy { public int[] thePouring(int[] capacities, int[] bottles, int[] fromId, int[] toId) { for(int i = 0; i < fromId.length; ++i){ bottles[toId[i]] += bottles[fromId[i]]; int over = bottles[toId[i]]>capacities[toId[i]]?bottles[toId[i]]-capacities[toId[i]]:0; bottles[fromId[i]] = over; bottles[toId[i]] -= over; } return bottles; } }