Submission #989625

#TimeUsernameProblemLanguageResultExecution timeMemory
989625MuhammetBank (IZhO14_bank)C++17
71 / 100
1082 ms856 KiB
#include <bits/stdc++.h> using namespace std; #define N 305 #define ll long long int #define sz(x) (int)x.size() #define ff first #define ss second int T, n, a[N], b[N], m; vector <int> v[N]; map <int,bool> vis; int main(){ ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for(int i = 1; i <= n; i++){ cin >> a[i]; } for(int i = 1; i <= m; i++){ cin >> b[i]; } for(int i = 1; i <= n; i++){ for(int j = 0; j < (1<<m); j++){ int x = 0; for(int j1 = 0; j1 < m; j1++){ if((j>>j1) & 1) x += b[j1+1]; } if(x == a[i]){ v[i].push_back(j); } } } vector <int> v1 = v[n], v2; if(sz(v1) == 0) return cout << "NO", 0; for(int i = n-1; i >= 1; i--){ v2.clear(); vis.clear(); for(auto i1 : v[i]){ for(auto i2 : v1){ if(((i1&i2) == 0) and (vis[i1+i2] == 0)){ vis[i1+i2] = 1; v2.push_back(i1+i2); } } } v1 = v2; if(sz(v1) == 0){ return cout << "NO", 0; } } cout << "YES"; 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...