Woburn Challenge 2015-16 Round 3 - Senior Division

What is a savior but an emblem of hope – but a monument for the people to look up to? Should he be anything that the world needs him to be – or should he be none of it? What does a savior owe the world? The time has come for the man of steel to finally face these difficult questions. And while Superman is nothing short of a god amongst mortals, Batman is... well, Batman.
Superman knows that fighting the dark knight is going to be no easy task. He knows that Batman will enter the battle with a heavily armored mech-suit with a multitude of unpredictable special abilities. It is very likely that Batman's armor will already be prepped to take on the stupendously powerful blows that Superman can deal. From collaborating with the U.S. government, Superman has received intel saying that Batman's suit has the ability to absorb the kinetic energy from any strike dealt onto it and store it for later use to power Batman's own offensive blows. This is an incredibly sneaky technology, and seems to give Batman a huge edge in battle. However, he has also learned this advanced technology has not yet been perfected. That is, the armor itself may fail at capturing the kinetic energy of the blows, resulting in actual damage being done. Luckily, Superman found out about it beforehand and now has a chance to plan out his attack strategy.
In particular, Superman plans to land
punches
onto Batman's armor. The punches are numbered from
to
, and he will
deal them in order. By analyzing the stolen blueprint of the mech-suit,
Superman knows that the
-th punch he lands on Batman will deal
units of damage to his suit.
Specifically, the damage will be negative if Batman's suit happens to
absorb
units of Superman's kinetic energy, or it will be
positive if the absorption fails and Superman successfully deals
units of damage.
Superman is no fool. In the battle, he will continue to perform punches
to
in order, but will stop as soon as the next punch would cause
the net damage on Batman's suit to become negative. The government will
do its best to help Superman by sabotaging Batman's suit beforehand, so
when the battle starts, the amount of initial damage sustained by
Batman's suit will be positive. Still, Superman would like to land as
many hits onto Batman as possible because it will nonetheless exhaust
the aging hero beneath the armor.
Since the only piece of information that Superman doesn't have is the
initial damage to Batman's suit when he enters the fight, he would like
your help in writing a program that can quickly compute how many punches
he'll throw based on the original damage to Batman's suit. In
particular, your program must answer
queries
where the
-th query asks: "if Batman's suit were to have
units of damage done to it when he enters the
battle, what is the number punches Superman will throw before making the
net damage to Batman's suit negative?"
In test cases worth of the points,
and
.
Input Specification
The first line of input contains two space-separated integers and
.
The second line of input contains space-separated integers
.
The third line of input contains space-separated integers
.
Output Specification
lines with a single integer on each line, the answers to queries
.
Sample Input
4 3
-3 5 -3 -3
2 3 4
Sample Output
0
3
4
Explanation
If Batman's suit starts with units of damage sustained from the
sabotage, then punching him would give him energy and immediately lower
the damage done to
, so Superman won't do it.
If the suit starts with units of damage, it will be lowered to
units
of damage after receiving the first blow, but raised to
units of
damage after the second blow, and lowered to
units of damage after the
third blow. By then, Superman will have realized that it's not
worthwhile to make the fourth blow (which will make the net damage
).
If the suit starts with units of damage, it will have sustained
units of damage going into the final blow. Thus Superman will be able to
deal the last punch and still have a nonnegative damage of
sustained
by the suit. Although this last punch seems to be suboptimal in
Superman's favor, he will still deal it nonetheless because he wants the
battle to be as long as possible to fatigue Batman.
Comments