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

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

Shopping Bags

시간 제한4초메모리 제한1024 MB

요약
크기 S1인 물건 N1개와 크기 S2인 물건 N2개를 용량 T인 가방에 담을 때 필요한 최소 가방 수를 구한다. 단, S2 >= T/4이다.
난이도

보통10점 중 6점

유형
그리디, 수학, 완전 탐색
정답자
아직 제출이 없습니다

문제

As usual, you forgot your reusable shopping bags at home. I guess you have to buy some paper bags. You only have two items on your shopping list, but you need to stock up on a certain quantity of each item since you are planing to throw a party. Each item has a size and the paper bags have a maximum total size they can hold. You will want to buy the fewest possible bags.

More precisely, you need to buy N_1N\_1 copies of the first item and N_2N\_2 copies of the second item. Each copy of the first item has size S_1S\_1 and each copy of the second has size S_2S\_2. The bags you can buy all have capacity TT, meaning they can hold any collection of items whose total size is at most TT.

Determine the fewest bags you must buy such that it is possible to distribute N_1N\_1 copies of the first item and N_2N\_2 copies of the second item between these bags while ensuring each bag receives a total item size of at most TT.

입력

The first line of input contains a single integer TT (1≤T≤1091 \leq T \leq 10^9). The second line contains integers N_1N\_1 and N_2N\_2 (1≤N_1,N_2≤2,0001 \leq N\_1, N\_2 \leq 2\\, 000) indicating the number of copies of the two items you must buy. The third line contains integers S_1S\_1 and S_2S\_2 (1≤S_1,S_2≤T1 \leq S\_1, S\_2 \leq T) giving the size of a single copy of the respective item. Additionally, the second item will be pretty big: S_2≥T/4S\_2 \geq T/4.

출력

Output a single integer BB on a line by itself indicating the fewest shopping bags that you need to purchase in order to pack all items into the bags.

예제3

  1. 예제 1

    입력
    10
    2 3
    2 6
    
    예상 출력
    3
    
  2. 예제 2

    입력
    6
    1 1
    3 4
    
    예상 출력
    2
    
  3. 예제 3

    입력
    7
    1 1
    3 4
    
    예상 출력
    1