Submission #385200

#TimeUsernameProblemLanguageResultExecution timeMemory
385200Aryan_RainaBank (IZhO14_bank)C++14
100 / 100
466 ms120792 KiB
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define int long long #define ld long double #define ar array const int INF = 1e15; const int MOD = 1e9+7; const int LIMIT = 1e18; const int MXN = 21; int a[MXN], b[MXN], can[MXN][1<<MXN]; vector<int> smh[1005*MXN]; vector<int> dp[MXN]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin>>n>>m; for (int i = 0; i < n; i++) cin>>a[i]; for (int i = 0; i < m; i++) cin>>b[i]; for (int i = 0; i < 1<<m; i++) { int sum = 0; for (int j = 0; j < m; j++) if ((i>>j) & 1) { sum += b[j]; } smh[sum].push_back(i); } dp[0] = {0}; can[0][0] = 1; for (int i = 0; i < n; i++) { for (int j : dp[i]) { for (int x : smh[a[i]]) if ((j & x) == 0 && !can[i+1][j^x]) { dp[i+1].push_back(j ^ x); can[i+1][j ^ x] = 1; } } } if (dp[n].size() > 0) { cout<<"YES\n"; } else cout<<"NO\n"; }

Compilation message (stderr)

bank.cpp:3: warning: ignoring #pragma comment  [-Wunknown-pragmas]
    3 | #pragma comment(linker, "/stack:200000000")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...