Submission #739921

#TimeUsernameProblemLanguageResultExecution timeMemory
739921Desh03Bank (IZhO14_bank)C++17
46 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; bool dp[21][1001]; int main() { int n, m; cin >> n >> m; vector<int> a(n), b(m), ok(n); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >> b[i]; dp[0][0] = 1; for (int i = 0; i < m; i++) for (int j = 0; j <= 1000; j++) { if (j + b[i] <= 1000) dp[i + 1][j + b[i]] |= dp[i][j]; dp[i + 1][j] |= dp[i][j]; } for (int i = 0; i < n; i++) for (int j = 0; j <= m; j++) if (dp[j][a[i]]) ok[i] = 1; for (int i = 0; i < n; i++) if (!ok[i]) { cout << "NO"; return 0; } cout << "YES"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...