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

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string.h>
#include<iostream>
#include<vector>
#include<map>

using namespace std;
const int maxn=1e3+6;
int a[maxn];

int main(){
	int n,m;
	while(~scanf("%d%d",&n,&m)){
		for(int i=1;i<=m;i++){
			scanf("%d",&a[i]);
		}
		sort(a+1,a+1+m);
		if(a[1]!=1){
			printf("NO\n");
			continue;
		}
		int flag=1;
		long long ma=1;
		for(int i=2;i<=m;i++){
			if(a[i]-1<=ma){
				ma=ma+a[i];
			}else{
				flag=0;
				break;
			}
		}
		if(ma>=n)printf("YES\n");
		else printf("NO\n");
	}
}