Magic Show
문제
Mårten the Magician is currently performing in a magnificent magic competition. The show consists of rounds. In each round, Mårten uses his magic to perform one of two tricks: either he makes some number rabbits appear, or he sabotages his opponents' tricks by making some number of their rabbits disappear. He can also choose to do neither.
For each rabbit Mårten makes appear or disappear, he must use 1 magick. In the beginning of the show, Mårten has magicks. When he has run out of magicks, he can no longer perform a trick.
The scoring of the competition is easy. In the :th round, let \[ S_i = \begin{cases} x & \text{ if Mårten made rabbits appear } \\ -y & \text{ if Mårten made rabbits disappear } \\ 0 & \text{ if Mårten didn't perform a trick} \end{cases} \]
In round , if is in the interval where and are integers specific to the round, he gets points. If is outside this interval, Mårten gets points. Note that Mårten cannot perform his magic on fractional rabbits, thus will always be an integer.
Mårten's total score in the competition is the sum of scores among all the rounds. What is the maximum score Mårten can get if he performs optimally?
입력
The sample judge reads input in the following format:
- line :
N K - line :
L[0] L[1] .. L[N - 1] - line :
R[0] R[1] .. R[N - 1]
출력
The sample judge writes output in the following format:
- line : the return value of
magic_score(N, K, L, R)on a line - line : integers, the values given from the calls to
trick(X)in order.
예제
예제 1
4 5 3 -2 -2 2 5 2 0 6
5 0 2 0 2