Solving Problem 1234A — Equalize Prices

Правка en7, от Sal3h.Sa3d, 2023-10-17 17:23:41

To solve this problem, we can apply a simple algorithmic approach. First, we calculate the sum of all the initial prices and divide it by the total number of products to find the average price. Then, we add the tolerance range ±k to the average price to obtain the minimum and maximum possible prices

Algorithm Explanation:

  1. Read the number of products n and the tolerance range k.
  2. Read the prices of the n products and calculate their sum.
  3. Calculate the average price by dividing the sum by n.
  4. Calculate the minimum possible price by subtracting k from the average price.
  5. Calculate the maximum possible price by adding k to the average price
Solution

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en8 Английский Sal3h.Sa3d 2023-10-17 17:24:00 3 (published)
en7 Английский Sal3h.Sa3d 2023-10-17 17:23:41 21 Tiny change: ' \n~~~~~\n<spoiler>\n' -> ' \n~~~~~\n\n'
en6 Английский Sal3h.Sa3d 2023-10-17 17:22:36 9 Tiny change: ' \n~~~~~\n<spoiler>\n' -> ' \n~~~~~\n\n' (saved to drafts)
en5 Английский Sal3h.Sa3d 2023-10-17 17:21:57 439
en4 Английский Sal3h.Sa3d 2023-10-17 17:16:34 0 Tiny change: 'To solve t' -> '`To solve t' (published)
en3 Английский Sal3h.Sa3d 2023-10-17 17:15:59 512
en2 Английский Sal3h.Sa3d 2023-10-17 17:15:11 18
en1 Английский Sal3h.Sa3d 2023-10-17 17:14:21 692 Initial revision (saved to drafts)