Precise Average 2 (avg2)

110 teams scored 6192 points on this task, for a maximum score of 100, an average score of 56 and a median score of 35.

Highlights

  1. Banfi, Vimercate is the institute with the most points (370).
  2. Lombardia is the region with the most points (2095).

Statement

Your friend John still works at the same shop and it still sells N products, numbered from 0 to N-1. Product i has a price of P_i bytedollars, where P_i is a positive integer. A recent Byteland law stated that the average of those prices must be exactly K, a positive integer. John has already tried to change the prices to comply with the law, but the boss was not satisfied with the result, since some prices changed too much. So he asked John for another way to change the prices! John is still busy, so he asked for your help: what is the minimum value of C for which it is possible to change each price P_i by at most C such that the average of the new prices is K? More formally, find the minimum value of C such that for the array of positive integers P = [P_0, P_1, …, P_N-1] there exists an array of positive integers P' = [P'_0, P'_1, …, P'_N-1] such that: (1) the average of the elements of P' is K, and (2) |P'_i - P_i| < C for each 0 < i < N...