Sal3h.Sa3d's blog

By Sal3h.Sa3d, history, 7 months ago, In English

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
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Sal3h.Sa3d (previous revision, new revision, compare).

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Sal3h.Sa3d (previous revision, new revision, compare).

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Sal3h.Sa3d (previous revision, new revision, compare).