fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int mod = 1e9+7;
  6. int n, target;
  7. cin >> n >> target;
  8. vector<int> x(n);
  9. for (int&v : x) cin >> v;
  10.  
  11. vector<vector<int>> dp(n+1,vector<int>(target+1,0));
  12. dp[0][0] = 1;
  13. for (int i = 1; i <= n; i++) {
  14. for (int j = 0; j <= target; j++) {
  15. dp[i][j] = dp[i-1][j];
  16. int left = j-x[i-1];
  17. if (left >= 0) {
  18. (dp[i][j] += dp[i][left]) %= mod;
  19. }
  20. }
  21. }
  22. cout << dp[n][target] << endl;
  23. }
Runtime error #stdin #stdout 3.55s 2095792KB
stdin
Standard input is empty
stdout
Standard output is empty