Start: Feb, 21, 2019 12:00:00
2018-2019 ACM集训队冬季集训第二次考核
End: Feb, 21, 2019 17:00:00
Time elapsed:
Time remaining:

Problem_ID: G
Result: Accepted
Time: 14ms
Memory: 1724kB
Author: 2017212212165
In contest: 1261

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
#include<math.h>
#include<vector>
#include<stack>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<stdio.h>
#include<functional>
#include<time.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 2e5 + 10;
const ll mode = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double pi = 3.14159265358979323846264338327950;
template <class T> inline T min(T a, T b, T c) { return min(min(a, b), c); }
template <class T> inline T max(T a, T b, T c) { return max(max(a, b), c); }
template <class T> inline T min(T a, T b, T c, T d) { return min(min(a, b), min(c, d)); }
template <class T> inline T max(T a, T b, T c, T d) { return max(max(a, b), max(c, d)); }

ll a[1010];
ll n,m;
int main()
{
	while(~scanf("%lld %lld\n",&m,&n))
	{
		ll sum=0;
		for(ll i=0;i<n;i++)
			scanf("%lld",&a[i]);
		sort(a,a+n);

		for(ll i=0;i<n;i++)
		{
			if(a[i]<=sum+1)
				sum+=a[i];
			else 
				break;
		}

		if(sum>=m)
			printf("YES\n");
		else
		    printf("NO\n");
	}
	
	return 0;
}