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

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

Flatland Currency

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

요약
500, 100, 50, 10, 5, 1엔 동전으로 N개 병을 여러 번 사고팔며 모을 수 있는 1엔 동전 수의 최댓값을 구한다.
난이도

보통10점 중 7점

유형
그리디, 수학, 구현
정답자
아직 제출이 없습니다

문제

The Flatland currency system uses coins of 500, 100, 50, 10, 5, and 1 Flatland yen.

At the shop in the Flatland airport, there are NN bottles of milkohol on sale; the ii-th bottle costs a_ia\_i yen. Note that there are exactly NN bottles, so you can buy each bottle no more than once.

You have XX flatland yen, and you noticed that the number of coins you have is minimal possible between all representations of XX.

In the shop, you can do the following sequence of actions any number of times:

  • Select some bottles.
  • Pay some of the coins you have for the selected bottles. 
  • The shop returns the change (if needed) using the least possible number of coins.
  • You may assume that the shop will never go short in any type of coins.

You promised your friends 1-yen coins as souvenirs. Find the maximum number of 1-yen coins that you can collect in this shop.

입력

The first line of input contains two integers NN and XX (1≤N≤1051 \le N \le 10^5, 1≤X≤10141 \le X \le 10^{14}): the number of bottles in the shop and the number of Flatland yens you have, respectively. The second line contains NN integers A_1,A_2,…,A_NA\_1, A\_2, \ldots, A\_N (1≤A_i≤1091 \le A\_i \le 10^9): the prices of the bottles in the shop.

출력

Print one integer: the maximum number of 1-yen coins you may have after visiting the shop.

예제2

  1. 예제 1

    입력
    5 57
    9 14 31 18 27
    
    예상 출력
    8
    
  2. 예제 2

    입력
    4 50
    11 11 11 11
    
    예상 출력
    12