아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Trade

면접 대비

시간 제한2초메모리 제한256 MB

요약
각 상품의 기본 가격과 구매할 때마다 오르는 추가 요금이 주어질 때, 예산 S로 살 수 있는 최대 상품 수를 구한다.
난이도

보통10점 중 6점

유형
정렬, 이분 탐색, 그리디, 누적 합
정답자
아직 제출이 없습니다

문제

It is the last day of your vacation and you decided to buy some memorabilia to remind you about these nice times. There are nn merchants, you liked one item from each one. The price written beside the item from ii-th merchant is c_ic\_{i}. You have SS money with you, and you are ready to spend them on the souvenirs. You don't have any preference so you just want to buy as many different items as possible. It would be an easy job but this is tourist shops we are talking about. They thrive on gullible tourists.

ii-th merchant has a persuasion parameter p_ip\_{i} and they are different for different merchants. The more souvenirs you already have, the more a merchant is sure about your willingness to spend money on worthless crap. If a merchant sees that you have already bought kk souvenirs, he raises the price on his souvenir to c_i+k⋅p_ic\_{i} + k \cdot p\_{i}.

What is the maximal number of souvenirs you can buy?

입력

The first line contains two integers nn and SS (1≤n≤1051 \le n \le 10^{5}, 0≤S≤1090 \le S \le 10^{9}) --- the number of merchants and the amount of money you have.

The second line contains initial prices of all the souvenirs c_1,c_2,…,c_nc\_{1}, c\_{2}, \ldots, c\_{n} (1≤c_i≤1091 \le c\_{i} \le 10^{9}).

The third line contains persuasion parameters of all the merchants p_1,p_2,…,p_np\_{1}, p\_{2}, \ldots, p\_{n} (0≤p_i≤1090 \le p\_{i} \le 10^{9}). It is guaranteed that they are distinct.

출력

Print one number --- how many souvenirs you can buy.

예제3

  1. 예제 1

    입력
    2 5
    1 1
    10 11
    
    예상 출력
    1
    
  2. 예제 2

    입력
    2 22
    10 1
    0 10000
    
    예상 출력
    2
    
  3. 예제 3

    입력
    1 0
    1
    0
    
    예상 출력
    0