Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- using namespace std;
- int main() {
- ifstream fin("input.txt");
- ofstream fout("output.txt");
- int n, m;
- fin >> n >> m;
- vector<bool> vec(m+1);
- vec[0] = 1;
- for (int i = 0; i < n; i++) {
- int a; fin >> a;
- for (int j = m - a; j >= 0; j--) if (vec[j]) vec[j + a] = 1;
- }
- fout << (vec[m] ? "YES" : "NO") << endl;
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment