Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int n;
- int k;
- int niza[105];
- int dp[100005];
- using namespace std;
- int main()
- {
- cin>>n;
- cin>>k;
- int mod = 1e9 + 7;
- for(int i=0; i<n; i++){
- cin>>niza[i];
- }
- for(int j=0; j<=k; j++){
- dp[j] = 0;
- }
- dp[0] = 1;
- // dp[j] --> broj na nacini da stigneme so j candies
- for(int i = 0; i < n; i++) {
- for(int j = k; j >= 0; j--) {
- for(int p = 1; p <= min(niza[i], k - j); p++) {
- dp[j + p] += dp[j];
- dp[j + p] %= mod;
- }
- }
- }
- cout << dp[k] << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement