HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Repetition (Loops) > problem:


012. 50589 - The Number of Eggs Sold

Guest
• Review clarifications (2)

Volume problems

• 004. 50424 - Area
• 004. 50522 - Multiplication Table - 2
• 005. 50297 - Divisible By Five
• 006. 50293 - Sum of odd numbers f...
• 007. 50401 - Sum of Odd Numbers
• 009. 50783 - The smallest number
• 010. 50782 - Max of N integers
• 012. 50352 - Selling Cows
• 012. 50589 - The Number of Eg...
• 015. 50466 - Drawing Square From...
• 016. 50463 - Drawing a Triangle
• 017. 50423 - Numbers square
• 017. 50537 - esreveR Triangle
• 018. 50344 - Profit or Loss
• 018. 50491 - Brokers
• 018. 50787 - Expected Value
• 019. 50438 - Pattern with stars

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