Solving Problem 1234A — Equalize Prices

Revision en2, by Sal3h.Sa3d, 2023-10-17 17:15:11

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

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en8 English Sal3h.Sa3d 2023-10-17 17:24:00 3 (published)
en7 English Sal3h.Sa3d 2023-10-17 17:23:41 21 Tiny change: ' \n~~~~~\n<spoiler>\n' -> ' \n~~~~~\n\n'
en6 English Sal3h.Sa3d 2023-10-17 17:22:36 9 Tiny change: ' \n~~~~~\n<spoiler>\n' -> ' \n~~~~~\n\n' (saved to drafts)
en5 English Sal3h.Sa3d 2023-10-17 17:21:57 439
en4 English Sal3h.Sa3d 2023-10-17 17:16:34 0 Tiny change: 'To solve t' -> '`To solve t' (published)
en3 English Sal3h.Sa3d 2023-10-17 17:15:59 512
en2 English Sal3h.Sa3d 2023-10-17 17:15:11 18
en1 English Sal3h.Sa3d 2023-10-17 17:14:21 692 Initial revision (saved to drafts)