408355: GYM103104 F Battery

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Batterytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Mr. X is a blogger of pilipili. He usually earns money by uploading videos taken by UAV(Unmanned Aerial Vehicle) to pilipili. One day, Mr. X comes to a new scenery spot. This scenery spot has $$$M$$$ shooting locations. It takes a UAV to shoot a continuous video with a length of $$$b_i$$$ seconds at $$$i^{\rm{th}}$$$ shooting location. The UAV uses a battery at one time to provide power, and the battery cannot be replaced during the shooting. But Mr. X only carried $$$N$$$ UAV batteries, each with different capacity. The $$$i^{\rm{th}}$$$ battery can support UAV shooting for $$$a_i$$$ seconds.

In order to attract more viewers, Mr. X hopes to shoot videos at as many shooting locations as possible. How many shooting locations can Mr. X shoot a video at most, with the $$$N$$$ UAV batteries he carries, if he takes the best strategy? (assuming that it does not take time for the UAV to take off, land and switch to another shooting location)

Input

The first line contains two integers: $$$N,M\ \ (1\le N\le 10^5,1\le M\le 3\times 10^5)$$$, which represent the number of batteries and the number of viewfinder positions.

Next line contains $$$N$$$ integers $$$a_1 \ldots a_n(1\le a_i\le 2^{30})$$$, which represent the capacity of the $$$i^{\rm{th}}$$$ UAV battery.

The third line contains $$$M$$$ integers $$$b_1 \ldots b_m (b_i=2^j,0 \leq j \leq 30 )$$$, which indicate the shooting duration of the $$$i$$$ shooting locations.

Output

Output one integer indicates the maximum number of shooting locations Mr. Xie can shoot a video, with the best strategy.

ExampleInput
2 4
3 5
2 2 2 2
Output
3

加入题单

上一题 下一题 算法标签: