Smart Thermostat (sensor)

249 teams scored 24165 points on this task, for a maximum score of 100, an average score of 97 and a median score of 100.

Highlights

  1. ITI Planck, Villorba is the institute with the most points (1300).
  2. Lombardia is the region with the most points (3870).

Statement

Edoardo is getting interested in making his house smarter. For this reason, he has bought a smart thermostat, which measures the temperature in his room. Edoardo has gathered so far N measures V_i produced by the sensor and would like to calculate some statistics. However, the thermostat is not always able to produce a stable measurement: in the case of an unreliable reading, V_i = -1 is reported as a special value instead of the correct measure of the room's temperature. The N measurements were all obtained at regular intervals in a single morning, starting just after switching on the heating system. For this reason, we are certain that during the whole morning the temperature of the room was non-decreasing. Edoardo wants to fix the errors by changing all the unreliable measurements so that they respect the non-decreasing property (formally, V_i > V_i-1 for each i = 1… N-1). What is the minimum sum of the measurements that he can get?