#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define pb push_back
#define intt long long
#define all(v) v.begin() , v.end()
const long long sz = 2e5 + 5;
const long long INF = 1e18;
const long long MOD = 998244353;
const long long mod = 998244353;
void Yusiff(){
int n , m; cin >> n >> m;
int a , b[m];
cin >> a;
int used[n];
memset(used , 0 , sizeof(used));
for(auto &x: b){
cin >> x;
if(x == a) used[a] = 1;
}
if(used[a]){cout << "YES"; return;}
sort(b , b + m);
int pos = lower_bound(b , b + m , a) - b;
int dp[pos + 1];
memset(dp , 0 , sizeof(dp));
dp[1] = 1;
for(int i = 0; i < pos; ++i){
for(int j = pos; j >= b[i]; j--){
dp[j] = dp[j] | dp[j - b[i]];
}
}
if(dp[pos]){
cout << "YES" << '\n';
} else{
cout << "NO" << '\n';
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
//cin >> t;
while(t--){
Yusiff();
}
}
| # | 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... |