Submission #871269

#TimeUsernameProblemLanguageResultExecution timeMemory
871269anarch_yBank (IZhO14_bank)C++17
25 / 100
3 ms2652 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define all(x) begin(x), end(x) #define pb push_back int main(){ int n, m; cin >> n >> m; vector<int> a(n), b(m); for(int i=0; i<n; i++) cin >> a[i]; int tot = 0; for(int i=0; i<m; i++){ cin >> b[i]; tot += b[i]; } int sum[(1<<m)]; vector<int> arr[tot+1]; for(int s=0; s<(1<<m); s++){ int t = 0; for(int p=0; p<m; p++){ if(s&(1<<p)) t+=b[p]; } sum[s] = t; arr[t].pb(s); } int dp[(1<<m)][n+1] = {}; for(int s=0; s<(1<<m); s++){ dp[s][0] = 1; } for(int i=1; i<=n; i++){ int t = a[i-1]; for(int s=0; s<(1<<m); s++){ for(auto u: arr[t]){ if((s&u)==u){ dp[s][i] |= dp[s^u][i-1]; } } } } if(dp[(1<<m)-1][n]) cout << "YES"; else cout << "NO"; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:16:9: warning: variable 'sum' set but not used [-Wunused-but-set-variable]
   16 |     int sum[(1<<m)];
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...