Submission #330703

#TimeUsernameProblemLanguageResultExecution timeMemory
330703hakanaiBank (IZhO14_bank)C++17
71 / 100
1091 ms18476 KiB
// https://oj.uz/problem/view/IZhO14_bank #include <bits/stdc++.h> using namespace std; const int N = 1010; vector<int> mp[N]; 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<N ) mp[res].push_back(s); } unordered_set<int> avail; avail.insert((1<<m)-1); for ( int i=0; i<n; i++ ) { unordered_set<int> navail; bool ok = false; for ( int t:mp[a[i]] ) { for ( int s:avail ) { if ( (t&s)==t) { if ( (s^t)>0 ) navail.insert(s^t); ok = true; } } } if ( !ok ) { cout << "NO" << '\n'; return 0; } avail = navail; } 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...