HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > CEN303 2013-15 Questions > problem:


14-Fall2-20. 50794 - Writing Files Into HDD

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

Guest
• Review clarifications (2)

Contest problems

• 13-Fall2-50. 50686 - The Container
• 14-Fall1-10. 50740 - Service Time - 1
• 14-Fall1-20. 50750 - Service Time - 2
• 14-Fall1-30. 50771 - BST Level Sum
• 14-Fall1-40. 50683 - Parking Buses
• 14-Fall1-50. 50770 - Average Depth
• 14-Fall1-60. 50784 - Top Growing C...
• 14-Fall2-10. 50751 - The biggest Mi...
• 14-Fall2-20. 50794 - Writing Fi...
• 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

Feedback

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

Time limit 2000/4000/4000/4000 ms. Memory limit 2500/25000/65000/65000 Kb.
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