Exam Supervisors
InterviewTime limit2sMemory limit512 MB
Each room needs one chief who covers B candidates plus enough assistants covering C each, so sum 1 + ceil(max(0, Ai - B) / C) over all rooms.
- Level
Easy3 of 10
- Topics
- Math, Greedy, Implementation
- Solved
- No attempts yet
Problem
There are exam rooms, and each room has candidates in it. Room has candidates.
Supervisors come in two kinds, chief and assistant. One chief supervisor watches at most candidates in a single room, and one assistant supervisor watches at most candidates in a single room.
Every room must have exactly one chief supervisor, and it may have any number of assistant supervisors. No supervisor covers more than one room.
Every candidate in every room has to be watched. Write a program that finds the smallest number of supervisors that makes this possible.
Input
The first line has the number of exam rooms . ()
The second line has the candidate counts , separated by spaces. ()
The third line has and , separated by a space. ()
Output
Print the smallest number of supervisors needed to watch every candidate in every room, on one line.