Submission #978111

#TimeUsernameProblemLanguageResultExecution timeMemory
978111KasymKBank (IZhO14_bank)C++17
19 / 100
2 ms348 KiB
#include "bits/stdc++.h" using namespace std; int n, m; vector<int> a, b; const int N = 1e3 + 4; const int M = 20 + 5; // int dp[N][M]; bool f(int pos, int sum){ if(pos == m){ if(sum == a.front()) return 1; return 0; } if(f(pos + 1, sum + b[pos])) return 1; if(f(pos + 1, sum)) return 1; return 0; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); // memset(dp, -1, sizeof dp); cin >> n >> m; a.resize(n); b.resize(m); for(int &i : a) cin >> i; for(int &i : b) cin >> i; cout << (f(0, 0) ? "YES" : "NO") << "\n"; 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...