# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
683106 | 2023-01-17T17:07:43 Z | brijeshSiwach | Bank (IZhO14_bank) | C++17 | 78 ms | 172748 KB |
//----------------------- JAI BABA KI -----------------------// #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<ll,ll> pl; typedef vector<pl> vpl; #define all(x) x.begin(), x.end() #define nl cout<<"\n" #define ar array #define PRECISION 9 #define fast_IO ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL) #define clock() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n" #ifdef LOCAL #include "../Library/debug.h" #else #define dbg(...) "OM BHOLE" #endif //----------------------- ये कर लो पहले -----------------------// const int mxN=1<<21; int n, m, a[mxN], b[mxN], dp[21][mxN]; unordered_map<int,vector<int>> maskp; int go(int pos, int mask){ if(pos==n) return 1; if(dp[pos][mask]==-1){ int ans=0; for(int smask: maskp[a[pos]]){ if(mask&smask) continue; ans|=go(pos+1,mask|smask); } dp[pos][mask]=ans; } return dp[pos][mask]; } void solve(){ 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&(1<<j)) sum+=b[j]; } maskp[sum].push_back(i); } memset(dp,-1,sizeof(dp)); cout<<(go(0,0)==1?"YES\n":"NO\n"); } //----------------------- पढाई कर ले -----------------------// int main(){ if (0) cout<<fixed<<setprecision(PRECISION); fast_IO; int T=1; // cin>>T; freopen("bank.in", "r",stdin); freopen("bank.out", "w",stdout); while(T--){ solve(); clock(); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 78 ms | 172748 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 65 ms | 172648 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 66 ms | 172636 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 78 ms | 172748 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |