Appy and Balloons

All submissions for this problem are available.
###Read problems statements [Hindi](http://www.codechef.com/download/translated/OCT18/hindi/HMAPPY.pdf) ,[Bengali](http://www.codechef.com/download/translated/OCT18/bengali/HMAPPY.pdf) , [Mandarin chinese](http://www.codechef.com/download/translated/OCT18/mandarin/HMAPPY.pdf) , [Russian](http://www.codechef.com/download/translated/OCT18/russian/HMAPPY.pdf) and [Vietnamese](http://www.codechef.com/download/translated/OCT18/vietnamese/HMAPPY.pdf) as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloons Appy wants on day $i$ by $A_i$. The problem is that you only have $M$ balloons. Fortunately, you can give her candies instead of balloons as well. On each day $i$, Appy accepts $B_i$ candies per each balloon you do not give her — formally, if you give Appy $X_i$ balloons on day $i$, then you have to give her $C_i = \mathrm{max}(0, A_i  X_i) \cdot B_i$ candies as well. Your task is to minimize the maximum number of candies you give Appy on some day — find the minimum possible value of $\mathrm{max}(C_1, C_2, C_3, ..., C_N)$. ### Input  The first line of the input contains two spaceseparated integers $N$ and $M$.  The second line contains $N$ spaceseparated integers $A_1, A_2, \dots, A_N$.  The third line contains $N$ spaceseparated integers $B_1, B_2, \dots, B_N$. ### Output Print a single line containing one integer — the minimum value of $\mathrm{max}(C_1, C_2, C_3, ..., C_N)$. ### Constraints  $1 \le N \le 10^5$  $0 \le M \le 10^{18}$  $0 \le A_i \le 10^{9}$ for each valid $i$  $0 \le B_i \le 10^{9}$ for each valid $i$ ### Subtasks **Subtask #1 (27 points):**  $1 \le A_i \le 10$ for each valid $i$  $1 \le B_i \le 10$ for each valid $i$ **Subtask #2 (73 points):** original constraints ### Example Input ``` 5 3 1 2 3 4 5 1 2 3 4 5 ``` ### Example Output ``` 15 ``` ### Explanation If you give Appy $0, 0, 0, 1, 2$ balloons on days $1$ through $5$, then the required numbers of candies on each day are $1, 4, 9, 12, 15$. The maximum number of candies is $15$, required on day $5$.Author:  hmrockstar 
Editorial  https://discuss.codechef.com/problems/HMAPPY 
Tags  binarysearch, easy, hmrockstar, oct18 
Date Added:  11092018 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 