제출 #1061977

#제출 시각아이디문제언어결과실행 시간메모리
1061977horezushol은행 (IZhO14_bank)C++14
19 / 100
69 ms4484 KiB
#include<bits/stdc++.h> #define F first #define S second #define SZ(x) int((x).size()) const char nl = '\n'; using ll = long long; using namespace std; const int N = 20; const int NA = 1010; int sum[(1 << N)]; vector<int> v[NA]; int a[NA], b[NA]; int n, m; void verkefni() { 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 mask = 0; mask < (1 << m); mask ++) { for (int i = 0; i < m; i ++) { if (mask & (1 << i)) sum[mask] += b[i]; } } for (int i = 0; i < n; i ++) { for (int mask = 0; mask < (1 << m); mask ++) { if (sum[mask] == a[i]) { v[a[i]].push_back(mask); } } } if (SZ(v[a[0]]) > 0) cout << "YES"; else cout << "NO"; // for (int i = 0; i < n; i ++) { // cout << a[i] << ": "; // for (auto el : v[a[i]]) { // cout << el << " "; // } // cout << nl; // } } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int tst = 1; // cin >> tst; while (tst --) { verkefni(); cout << nl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...