Submission #330704

#TimeUsernameProblemLanguageResultExecution timeMemory
330704hakanaiBank (IZhO14_bank)C++17
100 / 100
539 ms8684 KiB
// https://oj.uz/problem/view/IZhO14_bank #include <bits/stdc++.h> using namespace std; vector<int> mp[1005]; bool used1[1<<20], used2[1<<20]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<int> a(n), b(m); for ( int i=0; i<n; i++ ) cin >> a[i]; for ( int i=0; i<m; i++ ) cin >> b[i]; for ( int s=1; s<1<<m; s++ ) { int res = 0; for ( int i=0; i<m; i++ ) { if ( s>>i&1 ) res += b[i]; } if ( res<1005 ) mp[res].push_back(s); } used1[0] = 1; for ( int i=0; i<n; i++ ) { bool b = false; memset(used2, 0, sizeof(used2)); for ( int s=0; s<1<<m; s++ ) { if ( !used1[s] ) continue; for ( int t:mp[a[i]] ) { if ( (s&t)==0 ) { used2[s|t] = 1; b = true; } } } if ( !b ) { cout << "NO" << '\n'; return 0; } swap(used1, used2); } cout << "YES" << '\n'; return 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...