HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Search > problem:


50589 - The Number of Eggs Sold

Guest
• Review clarifications (2)

Section problems

• 50562 - List of students
• 50566 - Grade Point Average (GPA)
• 50570 - Prime numbers in the seg...
• 50573 - Count and Sum
• 50575 - Number of Prime numbers
• 50576 - Number of Perfect numbers
• 50586 - Prime Palindromes
• 50588 - Processing the list of numbers
• 50589 - The Number of Eggs Sold
• 50783 - The smallest number
• 50792 - The student with the highest...
• 50547 - Close Pair

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