This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
int INF = (int)2e9;
using namespace std;
template <class T>
istream& operator >>(istream &in, vector<T> &arr) {
for (T &cnt : arr) {
in >> cnt;
}
return in;
};
void solve() {
unsigned int n, m; cin >> n >> m;
vi a(n), b(m); cin >> a >> b;
vi used((int)2e5 + 1, 0);
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];
used[sum] = 1;
}
}
sum = 0;
int ans = 0;
for (int j = 0; j < n; ++j){
sum += a[j];
if (used[sum])
ans++;
}
if (ans == n){
cout << "YES";
return;
}
used.assign((int)2e5 + 1, 0);
}
cout << "NO";
}
int main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
#endif
solve();
return 0;
}
Compilation message (stderr)
bank.cpp: In function 'void solve()':
bank.cpp:30:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < m; ++j){
~~^~~
bank.cpp:38:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < n; ++j){
~~^~~
bank.cpp:43:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (ans == n){
~~~~^~~~
# | 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... |