Overload Prevention
InterviewTime limit1sMemory limit1024 MB
Given power strips with their socket counts, K wall outlets, and M devices with maximum strip-depth limits, find the most devices that can receive power.
- Level
Medium5 of 10
- Topics
- Greedy, Sorting, Simulation
- Solved
- No attempts yet
Problem
Eunha moved into a new home and brought electronic devices and power strips. The power strips have unlimited length.
The new home has wall outlets (). Eunha wants to connect the electronic devices to power using the power strips. A power strip may be plugged into a socket of another power strip. However, some devices use a lot of power. If power reaches such a device through more than a set number of power strips, the device may overload and catch fire.
Under these conditions, can Eunha connect as many devices to power as possible?
Input
The first line contains three integers , , and , the number of power strips, the number of wall outlets, and the number of electronic devices, separated by spaces. (, )
The second line contains integers , the number of sockets on each power strip, separated by spaces. ()
The third line contains integers , separated by spaces. is the maximum number of power strips that the current may pass through from a wall outlet to device . The number of power strips on the path to a device is the number of power strips the current passes through before reaching it. ()
A device with can only be connected directly to a wall outlet.
Output
Print the number of devices that receive power when as many devices as possible are powered.