Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int MAX = 500005;
- int32_t main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- int v, n;
- cin >> v >> n;
- vector<int> p(n);
- for(int &w : p)
- cin >> w;
- vector<int> dp(MAX);
- dp[0] = 1;
- for(int &w : p)
- for(int j = v; j >= w; j--)
- if(dp[j - w])
- dp[j] = 1;
- cout << (dp[v] ? 'S' : 'N') << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment