Submission #661275

#TimeUsernameProblemLanguageResultExecution timeMemory
661275hafoBank (IZhO14_bank)C++17
19 / 100
42 ms8404 KiB
#include <bits/stdc++.h> #define ll long long #define ull unsigned ll #define pb push_back #define pa pair<int, int> #define pall pair<ll, int> #define fi first #define se second #define TASK "test" #define all(x) x.begin(), x.end() using namespace std; template<typename T1, typename T2> bool mini (T1 &a, T2 b) {if(a > b) a = b; else return 0; return 1;} template<typename T1, typename T2> bool maxi (T1 &a, T2 b) {if(a < b) a = b; else return 0; return 1;} const int MOD = 1e9 + 7; const int LOG = 20; const int maxn = 20; const ll oo = 1e15 + 69; int n, m, a[maxn], b[maxn]; pa dp[1 << maxn]; bool getbit(const int mask, int i) { return ((mask >> i) & 1); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); //freopen(TASK".inp", "r", stdin); //freopen(TASK".out", "w", stdout); cin>>n>>m; for(int i = 0; i < n; i++) cin>>a[i]; for(int i = 0; i < m; i++) cin>>b[i]; fill_n(dp, (1 << m), make_pair(-1, 0)); dp[(1 << m) - 1] = {0, 0}; for(int mask = (1 << m) - 1; mask; mask--) if(dp[mask].fi != -1) for(int x = mask; x; x -= x&-x) { int i = dp[mask].fi, j = __builtin_ctz(x), s = dp[mask].se + b[j], add; if(s == a[i]) add = 1; else if(s < a[i]) add = 0; dp[mask ^ (1 << j)] = make_pair(i + add, add == 0 ? s:0); if(i + add == n) { cout<<"YES"; return 0; } } cout<<"NO"; return 0; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:44:84: warning: 'add' may be used uninitialized in this function [-Wmaybe-uninitialized]
   44 |                 int i = dp[mask].fi, j = __builtin_ctz(x), s = dp[mask].se + b[j], add;
      |                                                                                    ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...