# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
125628 | srvlt | 은행 (IZhO14_bank) | C++14 | 1072 ms | 10896 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define int long long
using namespace std;
int n, m, a[20], b[20], dp[20][(1 << 20)], s[(1 << 20)];
vector <int> d[20];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>m;
for (int i = 0; i < n; i++) {
cin>>a[i];
}
for (int i = 0; i < m; i++) {
cin>>b[i];
}
for (int i = 0; i < (1 << m); i++) {
for (int j = 0; j < m; j++) {
if (i & (1 << j)) {
s[i] += b[j];
}
}
for (int j = 0; j < n; j++) {
if (s[i] == a[j]) {
d[j].pb(i);
}
}
}
for (int i = 0; i < n; i++) {
dp[i][0] = 1;
}
for (int i = 0; i < n; i++) {
for (int j = 1; j < (1 << m); j++) {
for (int k = 0; k < d[i].size(); k++) {
if ((j & d[i][k]) == d[i][k]) {
if (i > 0) {
if (dp[i - 1][j ^ d[i][k]]) {
dp[i][j] = 1;
break;
}
} else {
dp[i][j] = 1;
break;
}
}
}
}
}
if (dp[n - 1][(1 << m) - 1]) {
cout<<"YES";
} else {
cout<<"NO";
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |