Submission #847585

#TimeUsernameProblemLanguageResultExecution timeMemory
847585Ahmed_Salah7Bank (IZhO14_bank)C++17
0 / 100
31 ms752 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 2e5 + 5, M = 1e6 + 6, mod = 998244353; vector<int> mask[22]; int a[22], b[22]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); freopen("bank.in","r",stdin); freopen("bank.out","w",stdout); int n, m; 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 < n; ++i) { for (int j = 0; j < (1 << m); ++j) { int sum = 0; for (int k = 0; k < m; ++k) { sum += b[k] * ((j >> k) & 1); } if (sum == a[i]) mask[i].push_back(j); } } vector<int> masks; masks.push_back(0); for (int i = 0; i < n; ++i) { vector<int> _masks; for (auto x: mask[i]) { for (auto y: masks) { if (!(x & y)) { _masks.push_back(x | y); } } } masks = _masks; } cout << (masks.empty() ? "NO":"YES"); }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     freopen("bank.in","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
bank.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen("bank.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...