Programming contests

ACM ICPC programozó csapatverseny, házi forduló, 2018. október 31.

October 31, 2018 10:10 AM – October 31, 2018 3:10 PM

Hard Choice

In long flights, airlines offer hot meals. Usually the flight attendants push carts containing the meals down along the aisles of the plane. When a cart reaches your row, you are asked right away: “Chicken, beef, or pasta?” You know your choices, but you have only a few seconds to choose, and you don't know how your choice will look like, because your neighbor hasn't opened his wrap yet…

The flight attendant in this flight decided to change the procedure. First, she will ask all passengers what choice of meal they would prefer, and then she will check if the number of meals available in this flight for each choice are enough.

As an example, consider that the available number of meals for chicken, beef, and pasta are respectively (80, 20, 40), while the number of passengers' choices for chicken, beef, and pasta are respectively (45, 23, 48). In this case, eleven people will surely not receive their selection for a meal, since three passengers who wanted beef and eight passengers who wanted pasta cannot be pleased.

Given the quantity of meals available for each choice and the number of meals requested for each choice, could you please help the flight attendant to determine how many passengers will surely not receive their selection for a meal?

Input Specification

The fist line contains three integers Ca, Ba, and Pa (0 ≤ CaBaPa ≤ 100), representing respectively the number of meals available for chicken, beef, and pasta. The second line contains three integers Cr, Br, and Pr (0 ≤ CrBrPr ≤ 100), indicating respectively the number of meals requested for chicken, beef, and pasta.

Output Specification

Output a single line with an integer representing the number of passengers who will surely not receive their selection for a meal.

Sample Input 1

  1. 80 20 40
  2. 45 23 48
download as text file

Output for Sample Input 1

  1. 11
download as text file

Sample Input 2

  1. 0 0 0
  2. 100 100 100
download as text file

Output for Sample Input 2

  1. 300
download as text file

Sample Input 3

  1. 41 42 43
  2. 41 42 43
download as text file

Output for Sample Input 3

  1. 0
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019