407775: GYM102892 4 Park Fountains

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

Description

4. Park Fountainstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

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 $$$q_i$$$ water fountains. In other words, each of the $$$q$$$ people is going to drink from all of the fountains from $$$1$$$ to $$$q_i$$$, inclusive (using 1-based indexing).

Unfortunately, some of the water fountains are going to break soon. The $$$i$$$th water fountain will break after at least $$$a_i$$$ people use it.

Each person will always use the fountains from $$$1$$$ to $$$q_i$$$, 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

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 <= a_i <= 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 $$$q_i$$$ $$$(1 <= q_i <= n)$$$: the number of water fountains that each person will drink at (from $$$1$$$ to $$$q_i$$$, inclusive).

Output

Output a single positive integer $$$k$$$: how many water fountains will break after all $$$q$$$ people use them.

Scoring

Subtask 1 (4 points): $$$1 <= n, q <= 1000$$$

Subtask 2 (13 points): no additional constraints

ExamplesInput
5 5
3 2 6 1 2
3
2
3
4
5
Output
3
Input
8 7
3 2 3 1 4 3 2 3
1
1
1
2
4
5
2
Output
3

加入题单

上一题 下一题 算法标签: