Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define pb push_back
- #define ALL(o) (o).begin(),(o).end()
- #define fo(n) for(int i=0;i<n;i++)
- #define fos(o,n) for(int i=o;i<=n;i++)
- int main(){
- int T;
- cin >> T;
- while( T-- ){
- int n , s;
- cin >> n >> s;
- int x[n] , c[s + 1];
- fo( n ) cin >> x[i];
- fo( s + 1 ) c[i] = 1e9;
- c[0] = 0;
- fo( n )
- for( int j = x[i] ; j < s + 1 ; ++j )
- c[j] = min( c[j] , c[ j - x[i] ] + 1 );
- cout << c[ s ] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement