Лимит времени 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
|
Для отправки решений необходимо выполнить вход.
|