# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
565724 | Halym2007 | 은행 (IZhO14_bank) | C++11 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ff first
#define ss second
#define cont continue;
#define sz size()
#define pb push_back
using namespace std;
typedef long long ll;
const int N = 100005;
int n, m, kl[25], c[25], a[25], b[25];
bool kp;
void solve(int x) {
if (x == m + 1) {
for (int i = 1; i <= m; ++i) {
kl[c[i]] += b[i];
}
for (int i = 1; i <= n; ++i) {
if (kl[i] != a[i]) kp = 1;
}
if (!kp) {
cout << "YES\n";
exit(0);
}
for (int i = 1; i <= m; ++i) {
kl[c[i]] = 0;
}
kp = 0;
return;
}
for (int i = 0; i <= n; ++i) {
c[x] = i;
solve (x + 1);
}
}
// 0 19 44 71 100
int main() {
freopen("bank.in", "r", stdin);
freopen("bank.out", "w", stdout);
cin >> n >> m;
for (int i = 1; i <= n; ++i) cin >> a[i];
for (int i = 1; i <= m; ++i) cin >> b[i];
if (n > m) return cout << "NO\n", 0;
solve (1);
cout << "NO\n";
}