#include #include #include using namespace std; int main() { int n, w; cin >> n >> w; vector a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector dp(w + 1, 1e9); dp[0] = 0; for (int j = 0; j < n; j++) { for (int i = a[j]; i <= w; i++) { dp[i] = min(dp[i], dp[i - a[j]] + 1); } } if (dp[w] == 1e9) cout << -1 << endl; // ÎÞ½â else cout << dp[w] << endl; return 0; }