Submission #1128158

#TimeUsernameProblemLanguageResultExecution timeMemory
1128158rasbery303Bank (IZhO14_bank)C++20
19 / 100
1 ms836 KiB
#include <iostream> using namespace std; const int N = 21; int n, m, a[N], b[N]; bool dp[N][N*1001]; int main(){ cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 1; i <= m; ++i) cin >> b[i]; dp[0][0] = 1; for (int i = 0; i < m; ++i){ for (int val = 0; val < 1001*N; ++val){ dp[i+1][val] |= dp[i][val]; dp[i+1][val+b[i+1]] |= dp[i][val]; } } bool ans = 0; for (int i = 1; i <= m; ++i){ ans |= dp[i][a[1]]; } cout << (ans? "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...