Snowball Fight
InterviewTime limit1sMemory limit1024 MB
Count the friends Jonas can hit, where a snowball is blocked by any snowdrift between the two positions that is taller than the shorter of the two heights.
- Level
Easy3 of 10
- Topics
- Array, Brute force
- Solved
- No attempts yet
Problem
Snow fell heavily overnight, so Jonas and his friends decided to have a snowball fight. Each of them took a position, and the battle is about to begin.
The battlefield is described by integers , which give the heights of the snowdrifts. The larger is, the taller the -th snowdrift is.
When Jonas throws a snowball from position , he can hit a friend at position if there is no snowdrift between them that is taller than .

In the figure above, Jonas (position 5, height 5) can hit Manta (position 2, height 4), but he cannot hit Asta (position 7, height 2).
Given the battlefield and the positions of Jonas and his friends, count how many friends Jonas can hit by throwing snowballs.
Input
The first line contains three integers , , and . is the size of the battlefield, is the number of Jonas's friends (not counting Jonas), and is Jonas's position.
The second line contains integers . Each value is the height of the corresponding snowdrift.
The third line contains distinct integers in increasing order. Each value is the position of a friend.
Output
Print one integer: the number of friends Jonas can hit by throwing snowballs.