Playing with barrels (barrels)

167 teams scored 5845 points on this task, for a maximum score of 100, an average score of 35 and a median score of 40.

Highlights

  1. Galileo Galilei, Trento is the institute with the most points (275).
  2. Lombardia is the region with the most points (1255).

Statement

For Christmas William will give to Giorgio a really nice present. Giorgio has always loved playing with barrels and his favorite game consists in taking N barrels, each of which has capacity C_i, and aligning them in a row in a way that when the i-th barrel gets full the water instantly goes to the (i+1)-th barrel. After setting up the barrels Giorgio will do either: (1) Put k liters of water in the u-th barrel; (2) Measure how many liters of water are there in the q-th barrel. Remember that barrels love overflowing: when some water flows in a full barrel it is all transferred to the next barrel. The last barrel overflows to the floor… but that's not our problem! Of course, William's present will be a fancy new simulator, not the real thing: help him writing it.