文章
79
粉丝
221
获赞
46
访问
202.1k
#include <iostream>
using namespace std;
int main() {
int sum, n;
while (cin >> sum >> n) {
int* a = new int[n];
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n&&sum>0;) {
if (sum - a[i] >= 0)
sum -= a[i];
else if (sum - a[i] < 0)
i++;
}
if (sum == 0)
cout << "YES";
else
cout << "NO";
cout << endl;
}
return 0;
}
登录后发布评论
只能过样例50%