HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > CEN303 2013-15 Questions > problem:


15HW-10. 50826 - Olive Containers

CEN303 2013-15 Questions

Start: Dec.15.2013 at 02:00:00 PM
Finish: Dec.15.2013 at 07:00:00 PM
The contest is finished!
• Contest scoreboard

Contest problems

• 14-Fall2-30. 50490 - Across the River
• 14-Fall2-40. 50772 - The Path of a N...
• 14-Fall2-50. 50681 - Center of a Series
• 14-FallResit-10. 50525 - Ordering Pizza
• 14-FallResit-20. 50488 - Connecting...
• 15FE-01. 50851 - Repeated Numbers
• 15FE-01. 50838 - Balanced Numbers
• 15FE-04. 50997 - Dynamic Knights
• 15HW-10. 50826 - Olive Contain...
• 15HW-30. 50828 - Arranging Time ...
• 15HW-40. 50676 - Cinema Millennium
• 15HW-40. 50829 - Decode an Image
• 15HW-50. 50830 - Sorting BST Nodes
• 15HW-60. 50678 - The Jumping Rabbit
• 15MdE-10. 50802 - Comparing Exams
• 15MdE-20. 50803 - Sum of the dept...
• 15MdE-40. 50805 - Sum of the weig...

Feedback

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

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

Olive Containers

You work in an olive oil factory. People bring olives with different amounts and you put olives to the containers. You can pour olive brought by a farmer to the first container where all the olive fit. If all the olive cannot be poured into this container, you try to pour it to the next container. If there is not enough space in any container the olive is not taken.

Question: Write a program that is going to read the capacities of m containers and n olive bottles brought by farmers. Then, show 1) Amount of olive which is not taken and 2) The total empty space in the containers.

Input specification
In the first line, you will be given two integers: The number of olive bottles brought by farmers (n) and the number of containers (m) in the factory where 0 ≤ m ≤ 200 and 1 ≤ n ≤ 2000. Then, in the following line, you will be given m integers, the capacities of m containers. The last line contains n integers amount of olives brought by farmers where the container capacities and olive amounts are integers between 0 and 10,000.

Output specification:
Show two information: 1) Amount of olive which is not taken and 2) The total empty space in the containers.

Sample Input I
5 2
10 12
6 7 3 4 5
Sample Output I
5 2

Explanation: There are 5 olive bottles brought by farmers, and two containers with the capacities: 10 and 12 liters.

  1. The first olive bottle (6 liters) is poured to the first container.
  2. The second olive bottle (7 liters) doesn't fit into the first container and it is poured into the second container
  3. The third bottle is poured into the first container. Then now, the first container has 9 liters.
  4. The fourth bottle is poured into the second container. Then now, the second container has 11 liters.
  5. There is not enough space in any container for the last bottle. So, it's not taken
Then, totally 5 liters olive is not taken. And, the containers contain 9 and 11 liters of milk. So, there is two liters space in two containers.



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

www.contester.ru