This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
using namespace std;
int a, b[22];
int m;
int getsum(int mask)
{
int res = 0;
int ind = m - 1;
while (mask)
{
if (mask & 1)
res += b[ind];
mask >>= 1;
ind--;
}
return res;
}
int main()
{
int n;
cin >> n >> m;
cin >> a;
for (int i = 0; i < m; i++)
cin >> b[i];
for (int mask = 1; mask < (1 << m); mask++)
{
int sum = getsum(mask);
//cerr << sum << '\n';
if (sum == a)
{
cout << "YES\n";
return 0;
}
}
cout << "NO\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |