PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#QHD0000005. Đổi tiền ít đồng nhất (Minimizing Coins)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đổi tiền ít đồng nhất (Minimizing Coins)

Minimizing Coins

Source: CSES

Problem Statement

You are given nn coin denominations c1,c2,…,cnc_1,c_2,\ldots,c_n. All denominations are pairwise distinct, and an unlimited number of coins of each denomination is available.

Choose coins whose total value is exactly xx, minimizing the number of coins used. If this is impossible, the answer is -1.

Input

The first line contains nn and xx: the number of denominations and the target sum.

The second line contains nn integers c1,c2,…,cnc_1,c_2,\ldots,c_n, the denominations.

Output

Print the minimum number of coins with total value xx, or -1 if no such selection exists.

Subtasks

  • Subtask 1 (20 points): 1≤n≤31\le n\le 3; 1≤x≤251\le x\le 25; 1≤ci≤1061\le c_i\le 10^6 (1≤i≤n1\le i\le n); the cic_i values are pairwise distinct.
  • Subtask 2 (30 points): 1≤n≤351\le n\le 35; 1≤x≤30001\le x\le 3000; 1≤ci≤1061\le c_i\le 10^6 (1≤i≤n1\le i\le n); the cic_i values are pairwise distinct.
  • Subtask 3 (50 points): 1≤n≤1001\le n\le 100; 1≤x≤1061\le x\le 10^6; 1≤ci≤1061\le c_i\le 10^6 (1≤i≤n1\le i\le n); the cic_i values are pairwise distinct.

Examples

Input

3 11
1 5 7

Output

3

Explanation

Using two 55-value coins and one 11-value coin gives 1111 with 33 coins. No combination of one or two coins from denominations 1,5,71,5,7 totals 1111.