Submission #760982

#TimeUsernameProblemLanguageResultExecution timeMemory
760982KubogiBank (IZhO14_bank)C++17
100 / 100
100 ms8632 KiB
#include <bits/stdc++.h> using namespace std; using i64 = long long; #define fileio(name) if (fopen(name".inp", "r")) freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout) const int maxn = 20; int n, m, a[maxn], b[maxn], pf[1<<maxn], rem[1<<maxn]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); fileio(""); // freopen("debug.txt", "w", stderr); cin >> n >> m; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < m; i++) { cin >> b[i]; } memset(pf, -1, sizeof pf); pf[0] = 0; for (int mask = 1; mask < (1<<m); mask++) { for (int i = 0; i < m; i++) { if (!((mask>>i)&1)) continue; int mask1 = mask ^ (1<<i); if (pf[mask1] == -1) continue; int val = rem[mask1] + b[i]; int target = a[pf[mask1]]; if (val < target) { pf[mask] = pf[mask1]; rem[mask] = val; } if (val == target) { pf[mask] = pf[mask1] + 1; rem[mask] = 0; } } if (pf[mask] == n) { cout << "YES"; return 0; } } cout << "NO"; return 0 ^ 0; }

Compilation message (stderr)

bank.cpp: In function 'int32_t main()':
bank.cpp:6:57: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define fileio(name) if (fopen(name".inp", "r")) freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout)
      |                                                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:14:5: note: in expansion of macro 'fileio'
   14 |     fileio("");
      |     ^~~~~~
bank.cpp:6:90: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define fileio(name) if (fopen(name".inp", "r")) freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout)
      |                                                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:14:5: note: in expansion of macro 'fileio'
   14 |     fileio("");
      |     ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...