Magic Show

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

Mårten the Magician is currently performing in a magnificent magic competition. The show consists of NN rounds. In each round, Mårten uses his magic to perform one of two tricks: either he makes some number xx rabbits appear, or he sabotages his opponents' tricks by making some number yy 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 KK magicks. When he has run out of magicks, he can no longer perform a trick.

The scoring of the competition is easy. In the ii:th round, let \[ S_i = \begin{cases} x & \text{ if Mårten made xx rabbits appear } \\ -y & \text{ if Mårten made yy rabbits disappear } \\ 0 & \text{ if Mårten didn't perform a trick} \end{cases} \]

In round ii, if S_iS\_i is in the interval \[L\[i],R\[i]]\[L\[i], R\[i]] where L\[i]L\[i] and R\[i]R\[i] are integers specific to the round, he gets S_iL\[i]+R\[i]2|S\_i - \frac{L\[i] + R\[i]}{2}| points. If S_iS\_i is outside this interval, Mårten gets 00 points. Note that Mårten cannot perform his magic on fractional rabbits, thus S_iS\_i 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 11: N K
  • line 22: L[0] L[1] .. L[N - 1]
  • line 33: R[0] R[1] .. R[N - 1]

출력

The sample judge writes output in the following format:

  • line 11: the return value of magic_score(N, K, L, R) on a line
  • line 22: NN integers, the values given from the calls to trick(X) in order.

제한

  • N1,000N \le 1\\,000
  • K1,000K \le 1,000