Raslboyy

1120

Aug 4th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     ifstream fin("input.txt");
  9.     ofstream fout("output.txt");
  10.  
  11.     int n, m;
  12.     fin >> n >> m;
  13.     vector<bool> vec(m+1);
  14.     vec[0] = 1;
  15.     for (int i = 0; i < n; i++) {
  16.         int a; fin >> a;
  17.         for (int j = m - a; j >= 0; j--) if (vec[j]) vec[j + a] = 1;
  18.     }
  19.     fout << (vec[m] ? "YES" : "NO") << endl;
  20.  
  21.     fin.close();
  22.     fout.close();
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment