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

Сборники > Data Structures > задача:


50794 - Writing Files Into HDD

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

Задачи сборника

• 50490 - Across the River
• 50816 - Largest Sum Path
• 50857 - Nine-Stones Game
• 50837 - Sum is equal to K
• 50772 - The Path of a Node
• 50936 - Saving the Soldiers
• 50447 - Swimming Contest - 2
• 50828 - Arranging Time Table
• 50794 - Writing Files Into HDD
• 50929 - Present from your uncles
• 50863 - Total Access Cost of a BST
• 50979 - Minimum access cost for BST
• 51000 - Book Index
• 51076 - Key person
• 51062 - Fish Pond II
• 51067 - Jumping frog
• 51080 - Deepest Point

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

Если у вас есть предложения или пожелания по работе 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