Geekflix

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

문제

George got COVID-19 in this morning. He must stay at home in the next seven days for quarantine. As a geek, George only watches Geekflix, the video streaming service for geeks, for recreation during his quarantine period. Geekflix provides nn video streams numbered from 11 to nn, and Geekflix also gives some geeky coins to the audiences in their quarantine periods. When George watches stream ii for the kk-th time in his quarantine period, George gets max(a_i(k1)b_i,0)\max{(a\_i - (k - 1)b\_i , 0)} geeky coins.

The Geekflix app arranges the video streams on a circle. For 1<in1 < i ≤ n, the previous stream of stream ii is stream i1i - 1. The previous stream of stream 11 is stream nn. For 1i<n1 ≤ i < n, the next stream of stream ii is stream i+1i + 1. The next stream of stream nn is stream 11. When George opens the Geekflix app on his TV, the Geekflix app points the cursor at stream 11.

The remote controller has three buttons: previous, next, and play. When George presses the previous button, the Geekflix app points the cursor to the previous stream. When George presses the next button, the Geekflix app points the cursor to the next stream. When George presses the play button, the Geekflix app plays the stream pointed by the cursor. The cursor points to the same stream after playing.

George may press the buttons mm times during his quarantine period, and he wants to get as many geeky coins as possible. What is the maximum number of geeky coins that George can get during his quarantine period?

입력

The first line contains two positive integers nn and mm. nn is the number of video streams, and George may press the buttons mm times. The second line contains nn positive integers a_1,,a_na\_1, \dots , a\_n, and the third line contains nn non-negative integers b_1,,b_nb\_1, \dots , b\_n. These 2n2n integers define the number of geeky coins awarded to George when the Geekflix app plays video streams.

출력

Output the maximum number of geeky coins that George can get during his quarantine period.

제한

  • 1n2001 ≤ n ≤ 200
  • 1m10001 ≤ m ≤ 1000
  • 0b_ia_i50000 ≤ b\_i ≤ a\_i ≤ 5000 for 1in1 ≤ i ≤ n.