Submission #899503

#TimeUsernameProblemLanguageResultExecution timeMemory
899503nasir_bashirovBank (IZhO14_bank)C++11
71 / 100
1053 ms68372 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> using namespace std; #define db long double #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define vi vector<int> #define vl vector<ll> #define vii vector<pii> #define vll vector<pll> #define endl '\n' #define all(x) x.begin(), x.end() #define fastio\ ios_base::sync_with_stdio(0);\ cin.tie(0);\ cout.tie(0)\ int a[25], b[25], dp[25][(1 << 20) + 5], n, m; vi can[25]; bool f(int i, int mask){ if(i == n + 1) return true; if(dp[i][mask] != -1) return dp[i][mask]; vi left; for(int j = 0; j < m; j++){ if(!((1 << j) & mask)){ left.push_back(j); } } for(int msk : can[i]){ if((msk & mask) == 0){ if(f(i + 1, (msk | mask))) return dp[i][mask] = 1; } } return dp[i][mask] = 0; } signed main(){ cin >> n >> m; for(int i = 1; i <= n; i++){ cin >> a[i]; } for(int i = 1; i <= m; i++){ cin >> b[i]; } for(int i = 1; i <= n; i++){ for(int mask = 0; mask < (1 << m); mask++){ dp[i][mask] = -1; int s = 0; for(int j = 0; j < m; j++){ if((1 << j) & mask){ s += b[j + 1]; } } if(s == a[i]){ can[i].push_back(mask); } } } f(1, 0); for(int mask = 0; mask < (1 << m); mask++){ if(dp[n][mask] == 1){ cout << "YES"; return 0; } } cout << "NO"; }

Compilation message (stderr)

bank.cpp: In function 'bool f(int, int)':
bank.cpp:37:60: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   37 |             if(f(i + 1, (msk | mask)))  return dp[i][mask] = 1;
      |                                                ~~~~~~~~~~~~^~~
bank.cpp:40:24: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   40 |     return dp[i][mask] = 0;
      |            ~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...