Submission #337630

#TimeUsernameProblemLanguageResultExecution timeMemory
337630kutbilim_oneBank (IZhO14_bank)C++14
0 / 100
2 ms492 KiB
/** kutbilim.one **/ #include <bits/stdc++.h> using namespace std; #define all(x) x.begin(),x.end() #define int long long #define endl '\n' signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); 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]; int MAX = *max_element(all(a)); vector<int> dp(MAX+1); dp[0] = 1; sort(all(b)); for(int i = m; i >= 0; i--){ for(int j = MAX-b[i]; j >= 0; j--){ if(dp[j] == true){ dp[j+b[i]] = true; break; } } } int result_out = 1; for(int i = 0; result_out && i < n; i++){ if(dp[a[i]] == false) result_out = false; } cout << (result_out ? "YES" : "NO"); 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...