-
Notifications
You must be signed in to change notification settings - Fork 0
/
NOCHANGE.cpp
48 lines (46 loc) · 1016 Bytes
/
NOCHANGE.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define lld long long int
//-4%3=-1
int main() {
// your code goes here
ios_base::sync_with_stdio(false);
cin.tie(NULL);
lld t;
//cin>>t;
t=1;
while(t--)
{
int n,k;
cin>>n>>k;
int v[k+1],sum[k+1]={0};
for(int i=1;i<=k;i++)
{
cin>>v[i];
sum[i]=sum[i-1]+v[i];
}
int dp[n+1]={0};
dp[0]=1;
for(int i=1;i<=n;i++)
{
if(dp[i]!=1)
{
for(int j=1;j<=k;j++)
{
if(i-sum[j]>=0&&dp[i-sum[j]])
{
dp[i]=1;
break;
}
}
}
}
if(dp[n])
cout<<"YES";
else
cout<<"NO";
}
}