Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int s[1001];
- int oshit[10001];
- int main()
- {
- int x;
- int inf = 4202137;
- cin >> x;
- for(int i = 0; i < x; i++)
- {
- cin >> s[i];
- }
- for(int i = 1; i <= 10000; i++)
- {
- oshit[i] = inf;
- }
- for(int i = 0; i < x ; i++)
- {
- for(int l = s[i]; l <= 10000; l++)
- {
- if(oshit[l - s[i]] != inf)
- {
- oshit[l] = oshit[l - s[i]] + 1;
- }
- }
- }
- int kwota;
- cin >> kwota;
- if(oshit[kwota] != inf)
- {
- cout << oshit[kwota];
- }
- else if(oshit[kwota] == inf)
- {
- cout << "NIE";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement