Solution
1634-Minimizing_Coins.cpp
1#include<bits/stdc++.h>
2using namespace std;
3#define int long long
4signed main(){
5 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
6 int n,x; cin>>n>>x;
7 vector<int> dp(x+1,3e18);
8 dp[0]=0;
9 for(int i=0;i<n;++i){
10 int e; cin>>e;
11 for(int j=e;j<=x;++j)
12 dp[j]=min(dp[j],dp[j-e]+1);
13 }
14 cout<<(dp[x]==3e18?-1:dp[x])<<'\n';
15 return 0;
16}Editorial not yet generated for this problem. Run the editorial generation script to add hints and detailed explanations.