fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int maxn = 1e6 + 7;
  5.  
  6. int n, s, a[maxn], f[201][50005];
  7.  
  8. int main(){
  9. cin >> n >> s;
  10. for(int i = 1; i <= n; ++i)
  11. cin >> a[i];
  12. f[0][0] = 1;
  13.  
  14. for(int i = 1; i <= n; ++i){
  15. f[i][0] = 1;
  16. for(int j = 1; j <= s; ++j){
  17. f[i][j] = f[i-1][j];
  18. if(j - a[i] >= 0){
  19. f[i][j] = max(f[i][j], f[i-1][j-a[i]]);
  20. }
  21. }
  22. }
  23. cout << f[n][s];
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
1