Submission #1098328

#TimeUsernameProblemLanguageResultExecution timeMemory
1098328vjudge1Bank (IZhO14_bank)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; bool can(vector<int> &a, vector<int> &b) { unordered_map<int, int> cnt; for(int i : b) { cnt[i]++; } for (int j : a) { vector<int> dp(j + 1, 0); dp[0] = 1; for(auto [i, r] : cnt) { for(int i = j; i >= 0; i--) { if(dp[i]) { for(int j = 1; j <= r && i + j * i <= j; j++) { dp[i + j * i] = 1; } } } } if(dp[j] == 0) { return false; } } return true; } int main() { int n, m; cin >> n >> m; vector<int> a(n), b(m); for(auto &i : a) { cin >> i; } for(auto &i : b) { cin >> i; } cout << (can(a, b) ? "YES" : "NO"); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...