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: 11ms
Memory: 1720kB
Author: 2018212212064
In contest: 1261

#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <iostream>
using namespace std;
const int maxn=int(1e3+10);
int money[maxn];
int main()
{
	int n,m;
	while(~scanf("%d%d",&n,&m))
	{
		for(int i=0;i<m;++i)
			scanf("%d",money+i);
		sort(money,money+m);
		long long ans=money[0];
		bool can=false;
		for(int i=1;i<m;++i)
		{
			can=false;
			if(money[i]>ans+1)break;
			can=true;
			ans+=money[i];
		}
		if(ans<n)can=false;
		else can=true;
		if( money[0] != 1 || can==false)printf("NO\n");
		else printf("YES\n");
	}
}