Question
You're the owner of a large park that contains n water fountains. q people are going to visit the park, and each of them is
You're the owner of a large park that contains n water fountains. q people are going to visit the park, and each of them is going to drink water from the first qi water fountains. In other words, each of the q people is going to drink from all of the fountains from 1 to qi, inclusive (using 1-based indexing).
Unfortunately, some of the water fountains are going to break soon. The ith water fountain will break after at least ai people use it.
Each person will always use the fountains from 1 to qi, regardless of whether or not these fountains are broken or not.
Given this information, your task is to figure out how many of the water fountains will be broken after the q people use them.
Input Format
The first line of input contains two space-separated integers n and q (1<=n,q<=100000): the number of fountains, and the number of people that are going to drink from the fountains, respectively.
The next line of input contains n space-separated integers: the array a (1<=ai<=200000), representing how many people need to drink from each fountain before it will break.
The next q lines each contain a single positive integer qi (1<=qi<=n): the number of water fountains that each person will drink at (from 1 to qi, inclusive).
Constraints
//
Output Format
Output a single positive integer k: how many water fountains will break after all q people use them.
Sample Input 0
5 5 1 2 3 4 5 1 2 3 4 5
Sample Output 0
3
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started