이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair
using namespace std;
typedef long long ll;
const ll inf = (ll)1e18 + 7;
const ll N = (ll)1e6 + 7;
int n,m;
int a[21],b[21];
int main () {
cin >> n >> m;
for (int i = 1; i <= n; i ++)
cin >> a[i];
for (int i = 0; i < m; i ++)
cin >> b[i];
for (int i = 0; i < (1 << m); i ++) {
int sum = 0;
for (int j = 0; j < m; j ++) {
if (i & (1 << j))
sum += b[j];
}
if (sum == a[1]) {
cout << "YES" << endl;
return 0;
}
}
cout << "NO" << endl;
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... |