1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
vector<uint16_t> paczki;
vector<unsigned long long> zbiory(5003, 0);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    uint16_t N;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        uint16_t paczka;
        cin >> paczka;
        paczki.push_back(paczka);
    }
    sort(paczki.begin(), paczki.end());
    zbiory[0] = 1;
    for (auto p : paczki)
    {
        const vector<unsigned long long> zbioryCopy = zbiory;
        for (int i = p - 1; i < 5002; ++i)
            if (i + p <= 5000)
                zbiory[i + p] = (zbiory[i + p] + zbioryCopy[i]) % 1000000007;
            else
                zbiory[5001] = (zbiory[5001] + zbioryCopy[i]) % 1000000007;
    }

    unsigned long long ans = 0;
    for (int i = 1; i < 5003; ++i)
        ans = (ans + zbiory[i]) % 1000000007;

    cout << ans;
    return 0;
}