Submission #1122340

#TimeUsernameProblemLanguageResultExecution timeMemory
1122340TAFHBank (IZhO14_bank)C++17
100 / 100
125 ms8696 KiB
#include <bits/stdc++.h> #define forn(i, n) for (int i = 0; i < n; i++) #define ull unsigned long long #define ll long long #define SPEED \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) using namespace std; const int N = 4e5 + 13; const int maxa = 2e5 + 13; const ll mod = 1e9 + 7; using tp = tuple<ll, ll, ll>; const int mxn = 30; void prestart() {} void start() { int n, m; cin >> n >> m; int a[n], b[m]; forn(i, n) cin >> a[i]; forn(i, m) cin >> b[i]; int covered[(1 << m)]; int left[(1 << m)]; fill(covered, covered + (1 << m), -1); fill(left, left + (1 << m), -1); covered[0] = 0; left[0] = 0; for(int s = 0; s < (1 << m); s++) { for(int i = 0; i < m; i++) { if (s & (1 << i) == 0) continue; int prev = s ^ (1 << i); if (covered[prev] == -1) continue; if (a[covered[prev]] > left[prev] + b[i]) { covered[s] = covered[prev]; left[s] = left[prev] + b[i]; } else if (left[prev] + b[i] == a[covered[prev]]) { covered[s] = covered[prev] + 1; left[s] = 0; } } } for(int s = 0; s < (1 << m); s++) { if (covered[s] == n) { cout << "YES" << "\n"; return; } } cout << "NO" << "\n"; } signed main() { SPEED; int t = 1; prestart(); // cin >> t; while (t--) { start(); } }

Compilation message (stderr)

bank.cpp: In function 'void start()':
bank.cpp:39:30: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   39 |             if (s & (1 << i) == 0) continue;
      |                     ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...