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

Разделы > Non-linear Data structures: Map, Set, Priority Queues > задача:


50794 - Writing Files Into HDD

Гость
• Вопросы к жюри (2)

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

• 50995 - Group Average
• 50983 - Course Selection
• 50517 - Confusion Matrix
• 50789 - Number of Cities
• 50993 - Products in store
• 50987 - Very Looong Queue
• 50869 - Birthday Celebration
• 50981 - Top popular m-students
• 50794 - Writing Files Into HDD
• 51000 - Book Index
• 51024 - Total Stock Price
• 51023 - Preparing Keyword Index
• 50706 - The most crowded Club
• 50793 - Top M Customers
• 50569 - Lendet me zgjedhje per kla...
• s

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

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

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 2500/25000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Writing Files Into HDD

For your National Science Academy, you are working on a new operating system. You want to prepare an algorithm to save the files. You know the positions and size of empty locations. You start with the biggest file and it is written to the biggest empty block. After writing the file to an empty block, the size of empty block is reduced according to the size of current file (sizeofEmptyBlock-=currentFileSize). If the biggest empty block is smaller than the current file size, then the current file continues from the next biggest empty block.

Question:Write a program that is going to read the sizes of n files and sizes of empty locations. In the end, your program should calculate and show the size of the biggest empty block.

Input specification
In the beginning, you will be given two integers: (n) the number of files and (m) the number of empty blocks. The next several lines will have the sizes of n files (separated by spaces and there are at most 25 numbers in every line). And the next several lines contain the size of m blocks where 0 ≤ (n and m) ≤ 50000 and the file sizes are between 0 and 1000000. The size of empty blocks are between 1 and 1000000000.

Output specification
Show one integer number: size of the biggest empty block.

Sample Input I
4 3
18 8 9 11
25 15 16
Sample Input II
4 4
4 3 9 9
5 8 5 12
Sample Output I
5
Sample Output II
3


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

www.contester.ru