ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Поиск > задача:


50826 - Olive Containers

Задачи раздела

• 50500 - Find Student
• 50786 - Top Question
• 50788 - Eight Puzzle
• 50504 - School contest
• 51056 - Welcome Picnic
• 50787 - Expected Value
• 51055 - The competition
• 50859 - Low performance
• 50826 - Olive Containers
• 50866 - Buy the cheapest
• 51077 - Grades Histogram
• 50785 - Swimming Contest
• 50999 - Overlapping Trips
• 50507 - Sequential Numbers
• 51057 - Number of students
• 50501 - The Highest Average
• 50434 - Row Min Subtraction

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
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