HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Repetition (Loops) > problem:


012. 50589 - The Number of Eggs Sold

Guest
• Review clarifications (2)

Volume problems

• 120. 50426 - Calculating Sales
• 50312 - Sales Bar Chart
• 50313 - Pattern Displays
• 50316 - Population Bar Chart
• 50336 - Buying Carpets
• 50295 - Weighted Average
• 003. 50358 - Series of Odd Numbers
• 005. 50297 - Divisible By Five
• 012. 50589 - The Number of Eg...
• 030. 50584 - Total invoice amount
• 050. 50450 - Last Appereance of a ...
• 060. 50362 - Pythagorean Numbers
• 060. Problem 2
• 065. 50394 - Water Bills
• 070. 50465 - How many students h...
• 075. 50363 - Class GPA Average
• 085. 50333 - Series of Squares

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 4000/7000/7000/7000 ms. Memory limit 65000/65000/65000/65000 Kb.
Prepared by Ibrahim Mesecan.

The Number of Eggs Sold

Shqip

Farmer Alban Shehu has a chicken farm. The chickens give several eggs everyday. Everyday, farmer Shehu keeps some of the eggs for home use (k) and he sells the rest to a shop. If the number of eggs that he has collected on that day is less than the number of eggs for home use (k), he keeps all the eggs for that day. If the number of the eggs is more than k, he keeps k eggs for home use and sells the rest.

Write a program that is going to calculate the number of eggs sold to the shop.

Input specification
The first line contains three numbers: the number of days (n), the numbers eggs (k) kept for home use, and the number of chickens in the farm (m) where 2 ≤ n ≤ 10000;    0 ≤ k ≤100;   and 0 ≤ m ≤ 1000. The following line contains n space separated numbers where each of the numbers is between 0 and m .

Output specification
Show the number of eggs sold to the shop at the end of n days.

Sample Input:
  7 3 9
  5 2 3 7 5 6 9

Sample Output:
  17

Output Explanation:

  • On the first day farmer Shehu has collected 5 eggs. He kept 3 for home use and he has sold 2 eggs to the shop
  • On the second day farmer Shehu has collected 2 eggs and he kept all for home use
  • On the third day farmer Shehu has collected 3 eggs and he kept all for home use
  • On the fourth day farmer Shehu has collected 7 eggs He kept 3 for home use, so he has 4 sold to the shop
  • etc.


Для отправки решений необходимо выполнить вход.

www.contester.ru