This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void S()
{
int n, m;
cin >> n >> m;
vector <int> a(m);
int x = 0;
for(int i = 0; i < m; i ++)
cin >> a[i], x += a[i];
vector <int> b(x+1);
b[0] = 1;
for(int i = 0; i < m; i ++){
for(int j = 0; j <= x - a[i]; j ++)
if(b[j] == 1)
b[j+a[i]] = 1;
}
cout << (b[n] == 1 ? "YES" : "NO");
/*for(int i = 0; i < x; i ++)
cout << b[i] << " ";*/
}
int main()
{
IOS;
/*int t;
cin >> t;
while(t --)*/
S();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |