Woburn Challenge 2015-16 Round 4 - Senior Division

James Bond's latest mission is not going as planned. He's suddenly found
himself at one end of a long, narrow corridor which is filled with
of Blofeld's henchmen. The
-th henchman is
standing
metres away from Bond along
the corridor.
There are also
doors in the corridor, all of
which are initially closed, with the
-th door
metres away from Bond along the corridor. Of the
henchmen and doors, no two of them are at the same location.
The building's security system will open all of the doors in order, one
after another, starting from door and ending with door
. Once each
door has been opened, it will stay open permanently. In order to do his
best to die another day, Bond will need to quickly assess how many of
the henchmen are currently in his line of fire after each door is
opened. A given henchman is in Bond's line of fire if there are no
closed doors between them and Bond.
Fortunately, Bond brought along his personal computer to the gunfight to
help with these computations. Unfortunately, he forgot to get the floppy
disk containing the program from Q! As quickly as you can, for each
from
to
, please help Bond determine how many of the
henchmen
will be in his line of fire after the first
doors have been opened.
Subtasks
In test cases worth of the points,
and
.
In test cases worth another of the points,
and
.
In test cases worth another of the points,
and
.
Input Specification
The first line of input consists of two space-separated integers and
.
The next lines each consist of a single integer
, for
.
The next lines each consist of a single integer
, for
.
Output Specification
Output lines with one integer per line. The
-th line of output
(for
) should consist of the number of henchmen in Bond's
line of fire after
doors have been opened.
Sample Input
5 4
2
300
4
15
1000000000
200
3
100
301
Sample Output
1
3
4
5
Comments