Flappy Bird Scoring
InterviewTime limit1sMemory limit512 MB
Given each obstacle's gap A_i minus B_i, find for each bird size w how many obstacles it passes before meeting a gap smaller than w.
- Level
Easy3 of 10
- Topics
- Array, Binary search
- Solved
- No attempts yet
Problem
Flappy Bird is a game where you dodge obstacles and travel as far as possible.
Each obstacle you dodge earns 1 point. The game has obstacles in total, and the -th obstacle is made of two obstacles. The top obstacle ends at position , and the bottom obstacle ends at position .
Sejeong, a Flappy Bird expert, can steer the bird to dodge the obstacles no matter how they are placed. (However, if the bird is larger than the gap between the obstacles, Sejeong cannot dodge them either.) That is, if the bird's size is larger than the gap of an obstacle, the bird cannot pass it. When the bird fails to pass an obstacle, the game ends immediately.

Several kinds of birds are given, one game each. For each bird, find how many points it can earn.
Print Sejeong's game score.
Input
The first line contains the number of obstacles .
The second line contains the top obstacle positions , separated by spaces.
The third line contains the bottom obstacle positions , separated by spaces. (The input is guaranteed to satisfy .)
The fourth line contains the number of birds to play.
The fifth line contains the size of each bird.
Output
For each bird, print the maximum game score Sejeong can earn, one score per line.